MADRID — Cristiano Ronaldo, the Portuguese soccer star, will pay about $22 million in back taxes and fines as part of a settlement reached with the Spanish tax authorities over undeclared earnings from his advertising contracts, prosecutors have said.

The settlement for Ronaldo, 33, follows a preliminary agreement reached last month, shortly before he played for his country in the 2018 World Cup in Russia and then moved clubs and countries, switching from Real Madrid to Juventus in Italy for a fee of about $110 million.

The settlement of 19 million euros includes a fine of €3.2 million for defrauding Spain of €5.7 million in taxes, according to a statement released on Thursday by the office of the attorney general of the Madrid region.

Ronaldo will also have to pay the back taxes, as well as interest charges on the amounts that he failed to make on schedule from 2011 to 2014, when he was playing for Real Madrid.