The ruling ended days of political stalemate and cleared the way for Prodi to start work on forming a government, which is unlikely to take office before the second half of May because of a constitutional log jam.
A statement by Prodi's Olive Tree coalition said after the court ruling: "The suspicions of fraud and the poisonous climate fuelled over the past few days by an unacceptable rhetoric in a democratic country have been swept away.
"Now it's time to turn the page and think about the problems of the country."
Berlusconi refused to concede defeat after the closest Italian election in modern history, saying he hoped checks on disputed ballots would show he had won the April 9-10 vote.
At one point he said the election had been rigged.
He made no immediate comment following the verdict, but Giulio Tremonti, the economy minister and a senior figure in Berlusconi's Forza Italia (Go Italy!) party, said the centre-right was not yet ready to acknowledge Prodi's victory.
However, not all Berlusconi's partners wanted to prolong the battle, with the centrist UDC party conceding defeat and wishing Prodi good luck.
After a week of checks, the court said in a statement that Prodi won the election in the lower house by 24,755 votes. Provisional results last week said the winning margin was a slightly higher 25,224 votes.
"Now it's time to turn the page and think about the problems of the country"
Romano Prodi statement
Despite the tight victory, Prodi's coalition will have almost 70 more seats than the centre-right in the 630-seat lower chamber, thanks to new rules introduced by Berlusconi last year. In the senate, however, it will have a two-seat majority.
Even if Berlusconi concedes, Italy faces weeks of limbo as a new government is unlikely to be appointed before the middle of May.
Under the Italian constitution, the head of state gives the election winner the mandate to govern.
But the transition process is complicated because the term of Carlo Azeglio Ciampi, the president, expires on May 18 and he wants his successor to nominate the new prime minister.
The new parliament, together with regional representatives, will pick a successor to Ciampi on May 12-13.
The narrow result has left many Italians wondering how long the next government will last and has unsettled financial markets, worried that Prodi will be too weak to push through unpopular reforms to tackle Italy's stagnant economy.
Even before the court's verdict, cracks within Prodi's coalition - which stretches from Roman Catholic moderates to communists - had started to show.
Within days of the election, the leader of Italy's most powerful trade union demanded the scrapping of a reform sought by Berlusconi's government to promote labour market flexibility.
That view is supported by Communist Refoundation, which will have a powerful voice in the next parliament thanks to its election showing. Prodi wants to modify the law, not abandon it altogether.
Berlusconi says Prodi will be unable to govern on his own and has proposed a German-style grand coalition in which left and right would join forces. Prodi has rejected this.