The Portugal and Juventus footballer Cristiano Ronaldo has admitted committing tax fraud while playing for Real Madrid and agreed to pay an €18.8m (£16.5m) fine after striking a deal with prosecutors and tax authorities in return for a 23-month suspended prison sentence.

Ronaldo, 33, had been accused of defrauding the authorities of €14.8m (£12.9m) in unpaid taxes between 2011 and 2014.

In 2017, Madrid’s regional state prosecutor alleged the player had used what it deemed to be a shell company in the Virgin Islands to “create a screen in order to hide his total income from Spain’s tax office”.

It said Ronaldo “intentionally” did not declare income of €28.4m (£25m) related to image rights, and declared €11.5m of earnings from 2011-14 when his real income was almost €43m.

The prosecutor also alleged that the forward falsely reported income as coming from real estate, which it said had greatly reduced his tax rate.

Ronaldo arrived in court in Madrid on Tuesday morning, wearing sunglasses and a black blazer and accompanied by his partner, Georgina Rodríguez. His request to be allowed to enter the Provincial court through an underground carpark was denied.

The brief hearing came six months after Ronaldo agreed a deal that would see him spared jail if he paid fines totalling almost €19m.

In Spain, a judge can suspend sentences for two years or less for first-time offenders.

Earlier, Ronaldo’s former teammate at Real Madrid, Xabi Alonso, walked in to face his own case of tax fraud, his hands deep in his suit pockets. “Yes, all good,” was his only response to journalists’ questions.

Alonso is accused of defrauding tax authorities of about €2m euros from 2010-12.

He could be sentenced to five years in prison and ordered to pay a fine of €4m, in addition to the amount allegedly defrauded. The charges are related to Alonso’s income from image rights. The retired Spain midfielder, who has denied any wrongdoing, played for Madrid from 2009-14.