Berlusconi had initially promised to topple the government by withdrawing his party's support - a move which prompted the Senate vote.
But he backed down when it became clear that several of his senators would back the government.
Mr Letta had earlier said that if he were defeated in the vote, it might prove a "fatal risk" for Italy.
In the event he won easily: the Senate voted 235 to 70 in favour of the government.
Some of Berlusconi's most hardline followers left the chamber and did not vote at all.
The result of the vote increases the possibility of Berlusconi being thrown out of the Senate on the grounds he is a convicted criminal.
On Friday a Senate committee is due to vote on whether to strip him of his seat following his conviction for tax fraud.
As he left the Senate building on Wednesday, people outside greeted him with catcalls, whistles and cries of "go away".
By Alan Johnston BBC News, Rome
Silvio Berlusconi believed he was in a position to torpedo this government.
And when he pulled out his ministers, he did tear a hole in it. But he did not manage to sink it.
It was going to be patched up with the help of rebels from his own ranks, and go sailing on.
As the scale of the mutiny became clear, Mr Berlusconi knew he could only try to limit the damage.
When he rose to speak he was forced into a humiliating U-turn.
He said he and his whole party would support the government that he had just tried to destroy.
Mr Berlusconi emerges from this affair weakened - his credibility undermined. His capacity to rock Italian politics to its core has been diminished.
Last weekend, Berlusconi demanded that five ministers from his centre-right People of Freedom party (PDL) leave the government and bring it down.
But some of his closest colleagues said they would defy him, and the BBC's Alan Johnston in Rome says it gradually became clear that Berlusconi had badly overreached himself.
Our correspondent says the former prime minister has been forced into a humiliating climbdown, and will emerge a weakened figure with his capacity to influence Italian politics diminished.
But Berlusconi's close ally Renato Schifani insisted he had not been weakened by the vote, telling Italian news agencies that his leadership "has been strengthened".
When he rose to speak in the Senate to announce his turnaround, Berlusconi said: "Italy needs a government that can produce structural and institutional reforms. We have decided, not without internal travail, to back the confidence vote."
The Milan stock exchange gained nearly 2% on the announcement.
In his address to the Senate, Mr Letta defended his government's performance and said Italy "runs a risk, a fatal risk" if it were to fall.
He said: "Give us your confidence to realise [our] objectives. Give us your confidence for all that has been accomplished... a confidence vote for Italy and Italians.''
Berlusconi had accused Mr Letta of allowing his "political assassination through judicial means" - a reference to Berlusconi's criminal conviction for tax fraud in August.
Berlusconi said he asked his ministers to defy the government to protest against an impending rise in VAT, not because of the attempts to throw him out of the Senate.
But the prime minister accused Berlusconi of using the VAT issue as an "alibi" for his own personal concerns.
He refused to accept the resignation of the five PDL ministers and hence called the vote of confidence.
Berlusconi's plan to bring the government down began to unravel when the ministers signalled their own unwillingness to leave the government, and even his deputy and party secretary, Angelino Alfano, said that PDL members should back Mr Letta.
Analysts say the crisis threatened to hamper badly needed reforms to tackle Italy's economic problems that include debt, recession and high youth unemployment.
Mr Letta's cross-party alliance was formed in April after two months of political deadlock following an inconclusive election.
Berlusconi dominated Italian politics for nearly two decades before resigning in November 2011, in the midst of a storm over the failing economy.
Despite legal woes and sex scandals, the 77-year-old billionaire has served as prime minister three times.
He was ousted from power in 2011, but nearly came back again earlier this year after an effective election campaign won him almost a third of the vote.
But recently it appears that his problems have begun to catch up with him.
He has been convicted for tax fraud - for which he will have to serve a one-year sentence, probably under house arrest or via community service because of his age.
He has also been sentenced to seven years in jail for paying for sex with 17-year-old prostitute Karima El-Mahroug, known as "Ruby the Heart Stealer", and for abuse of office. He is appealing against the verdict.
Despite some analysts saying his failure to topple the government spells his end in Italian politics, others are less sure, pointing out that he has endured numerous political setbacks in the past, only to re-emerge seemingly unscathed.
Lucio Malan, a senator from his party, told the BBC that Berlusconi would still be "the person who represents so many electors in Italy".
Italian Premier Enrico Letta has won a confidence vote after a last-minute U-turn by former PM Silvio Berlusconi.