Cristiano Ronaldo left Real Madrid to join Juventus in 2018. Getty

Cristiano Ronaldo was fined almost €19 million ($21.6 million) for tax fraud on Tuesday but will avoid serving a 23-month prison sentence.

The Juventus forward, who played for Real Madrid from 2009 to 2018, agreed to settle the case by paying an €18.8m fine and accepting a suspended jail sentence. Under Spanish law, a first offender can serve anything less than a two-year sentence under probation, and Ronaldo will not have to go to prison.

His court appearance lasted about 15 minutes, as he only needed to sign off on the previously settled agreement. Ronaldo had to enter the courtroom through the front door after his request for special security measures to avoid the spotlight was denied on Monday.

In 2017, Ronaldo denied an accusation that he knowingly used a business structure to hide income generated by his image rights in Spain between 2011 and 2014. After reaching the deal, he paid a fine of €5.7m, plus interest of about €1m, in July 2018, the prosecutor's office said last week.

Prosecutors had requested for Ronaldo to be handed a 23-month prison sentence. At his initial trial in July 2017, Ronaldo testified and said he strongly rejected any wrongdoing and told the judge he felt victimised by the Spanish authorities.

According to the prosecutor's report, Ronaldo "obtained significant income" from image rights between 2011 and 2014 and "should have paid tax in his subsequent declarations" to the Spanish authorities but failed to do so.

He departed Madrid last summer after nine seasons at the club to join Juventus in a €100m transfer. The former Manchester United player claimed that the treatment received by the Spanish authorities played a part in his desire to leave Madrid.

Ronaldo earns an estimated $93m (€80m) a year, according to Forbes, with approximately half coming from image-rights deals with his many sponsors.

Separately, Ronaldo is facing a rape allegation in the United States. Kathryn Mayorga filed a civil lawsuit in Nevada in September claiming Ronaldo raped her in his Las Vegas hotel room in 2009. Police reopened an investigation into the allegation at her request. Ronaldo has denied any wrongdoing.

The trial of Ronaldo's former Real Madrid teammate Xabi Alonso, also in court on Tuesday over accusations of tax fraud, was suspended, a court magistrate said. Alonso said he was confident he had not committed a crime and would have to wait while the magistrates evaluated his case.

"I'd be worried if I thought I had something to hide or something I didn't do right, but as that isn't the case I am carrying on," Alonso told reporters outside the court.

Information from The Associated Press and ESPN FC's Spain correspondent Adriana Garcia was used in this report.