The 75-year-old, who has held the office four times before, won 165 votes - exceeding the 136 required - with 83 votes against him, parliament speaker Agni Sapkota said.
He faces the immediate task of procuring vaccines and controlling the spread of COVID-19, which the government says has infected 667,109 people and killed 9,550. Public health experts say an under-reporting of cases in the country means the figures could be higher.
Fewer than 4% of the country's 30 million people have been fully vaccinated against COVID-19. More than 1.3 million people, who have had a first dose of a vaccine, are awaiting a second as the government scrambles to procure shots.
"Combating COVID will be the first priority of the new government," Deuba said in parliament.
The new government has pledged to vaccinate a third of its people in the next three months and every Nepali by next April.
Last Monday, the Supreme Court ordered Deuba be appointed premier in place of KP Sharma Oli. It ruled that Oli, who had been in power for three years, had breached the constitution by dissolving parliament. However Deuba still needed to win the confidence vote, under the constitution.
Deuba, head of the centrist Nepali Congress party, will head a coalition with former Maoist rebels and a party representing a minority community dominant on Nepal's southern plains.
Oli, 69, says he had been unfairly removed by the court and has vowed to "go to the people" to explain his position.
Pradeep Gyawali, a senior official in Oli's Communist Unified Marxist Leninist party, said the Oli government would be "remembered by the people for many good works it had done" while in power.