Milan (AFP) - An Italian appeals court on Friday cleared Silvio Berlusconi of having sex with an underage prostitute and abuse of power in a surprise ruling that will strengthen the former prime minister on the political scene.

"The defendant is acquitted," presiding judge Enrico Tranfa said, requesting silence after gasps from the courtroom.

The effectively scraps Berlusconi's seven-year sentence and lifelong ban from holding public office.

The judge said there was "no crime" on the abuse of power charge and that Berlusconi's actions "did not constitute a crime" on the prostitution one, promising to publish a detailed explanation within the three-month legal limit.

His lawyer Franco Coppi said the judge may have recognised the defence argument that Berlusconi did not know the girl in question was only 17 years old at the time.

"I am moved," the 77-year-old Berlusconi was quoted as saying in a tweet sent out by his Forza Italia party.

"Only those who have been close to me in these years know how much I suffered for an unjust accusation," he said, condemning "media aggression, gossip and slander".

Berlusconi, who has repeatedly accused prosecutors and judges of being biased against him, went on to praise magistrates, saying: "The majority of Italian magistrates does its work quietly, with admirable balance and rigour".

Berlusconi was not present at the hearing in Milan as he is doing his once-a-week community service at a centre for Alzheimer's patients for a separate tax fraud conviction linked to his business empire, Mediaset.

He left the centre at Cesano Boscone near Milan following the ruling without making any comment, while a lone supporter held up a sign reading: "Justice is served".

Prosecutors had asked the judges to uphold the suspended sentence against Berlusconi for paying for sex with an exotic dancer called Karima El-Mahroug, who is now better known by her stage name as "Ruby the Heart Stealer".

Berlusconi had also been convicted of pressuring the police while he was still prime minister to release the Moroccan-born dancer from custody when she was arrested for theft -- apparently out of concern that she could reveal their liaison.

Story continues

- 'More united' -

He said he only made the call because he thought she was then Egyptian president Hosni Mubarak's niece.

Prosecutors, who had relied on telephone wiretaps and statements made and then denied by El-Mahroug, could now apply to the supreme court to review the ruling.

The ruling will have political repercussions.

Berlusconi's Forza Italia party had been riven by internal divisions since a ruling against him would have opened the possibility of the ageing playboy being excluded from the political scene entirely.

"This ruling will bring people together. We will be calmer working in future and be more united between ourselves and with all of the centre-right," Lucio Malan, a Forza Italia senator, told the SkyTG24 news channel.

Berlusconi is not in the clear from legal woes just yet as he is currently on trial for allegedly bribing a senator with 3.0 million euros ($4.0 million) in 2006 to join his party and destabilise a centre-left government.

In another case, prosecutors have requested that he face trial on suspicion of paying off a pimp to provide false testimony in an investigation on prostitutes who attended parties at his residences in Milan and Rome.

Berlusconi is also being investigated for allegedly paying off witnesses -- young women who attended his soirees -- to provide false testimony in the Ruby trial.

The charges in that case have not yet been formally levied.

The legal saga also has political ramifications for Prime Minister Matteo Renzi since his centre-left government is relying on votes from Berlusconi's centre-right opposition coalition to pass through key constitutional reforms.

Italian media have reported that Berlusconi may be sticking to a pact with Renzi on the reforms, including an overhaul of the electoral law, in the hope of receiving an amnesty.