Most observers expected a tight vote, and both the Congress party and its opponents did whatever they could to muster their forces.
One ailing politician was wheeled in on a hospital bed and a handful jailed for crimes ranging from murder to extortion were temporarily released from prison so they could vote.
"It's a great victory for the party and the government, and this victory is dedicated to the future of the country," said Ambika Soni, a senior Congress party official.
Sohail Rahman, Al Jazeera's correspondent in New Delhi, said: "It seems at the moment that the prime minister and his future are secure ... But this whole debate around India's civilian nuclear deal has polarised politicians."
Opponents of the deal say the agreement would compromise India's position as a politically neutral country, and that the requisite UN inspections the deal requires would limit the country's ability to develop its weapons programme and deter Pakistan, its main regional rival.
They also argue that there are strings attached and doing a deal with the US would undermine India's freedom to buy oil and gas from countries such as Iran, or shop for armaments with traditional suppliers including Russia.
The government argues that the country of 1.1 billion people needs to develop alternative energy sources if it is to avert an expected fuel crisis.
India's left-wing parties triggered the confidence vote by withdrawing their support for Singh earlier in July.
As the results emerged, the White House praised Singh for "soldiering on" with the US-India nuclear pact, despite the opposition within India.
"Obviously, the politics in India have been tough to deal with, but he's been soldiering on and trying to build a consensus," Dana Perino, the White House spokeswoman, said.
"There's more support here than there at this time, but I know prime minister Singh has been working on it and he felt very confident" she said.
Prior to the vote, parliament was disrupted by three opposition legislators, waving wads of Indian rupees that they said they had been offered as bribes to abstain from voting.
Lal Krishna Advani, the opposition Bharatiya Janata Party (BJP) leader, alleged that three opposition members were given a total of 10 million rupees ($235,000) by government supporters as an advance payment for abstaining, and were offered much more.
Congress said the allegations were baseless.
"This is all drama, and it has been planted deliberately by the people who know they have lost the vote," Ashwini Kumar, a Congress spokesman, said.
"We are seriously looking into the allegations but the opposition knows we will win so they are resorting to such activities."
The parliamentary speaker adjourned proceedings as a result of the incident, but the vote later went ahead.