He received 162 votes of support to 157 in the poll.
Prodi, who has been in office for nine months, resigned last week after he was defeated in a foreign policy vote in the senate when some left-leaning members in his nine-party coalition voted against him because of their objections to the Italian deployment in Afghanistan.
Giorgio Napolitano, Italy's president, asked Prodi to stay on and the prime minister rallied his allies behind him, paving the way for the confidence vote.
Prodi's position remains shaky.
His popularity with the public is low and the splits in his coalition, which stretches from communists to moderate Catholics, still exist.
An opinion poll published by the La Repubblica newspaper in December showed Prodi's approval rating had plunged 25 points from 63 per cent to 38 per cent since September.
Prodi could face further opposition from inside his coalition when members of parliament vote on draft law that will allow civil unions for gay couples.
The issue has caused friction between Catholics and radical left-wing members of Prodi's coalition, as well as facing objections from the opposition and Vatican.
Prodi will also have to rely on support from his rival Silvio Berlusconi, the former prime minister, to keep Italian troops in the Nato mission in Afghanistan.
On Thursday, Berlusconi pledged to support funding for the deployment which could be defeated without votes from outside the coalition.
Berlusconi said his centre-right backers would vote to continue funding for the 1,800 troops "because the country must be serious and have a clear, loyal policy toward its allies".