MADRID – Lionel Messi will stand trial in Spain on three counts of tax fraud and could be sentenced to nearly two years in prison if found guilty.

A Spanish judge on Thursday rejected a request to clear the Barcelona player of wrongdoing and decided to charge him and his father, Jorge Horacio Messi, with tax fraud.

Prosecutors had said Messi — a four-time world player of the year — was not fully aware of his father's unlawful activities and should not have been charged, but the state attorney's office contended that the Argentina forward knew enough to also be named in the case.

The attorney's office called for a prison sentence of 22 months and 15 days for Messi and his father, along with a fine in the amount defrauded, payment of all legal proceedings and the loss of any possible tax benefits for a year and a half. Prosecutors had called for an 18-month prison sentence for Messi's father only, along with a fine of $2.2 million.

The company managing Messi's image rights, Leo Messi Management, defended the player, saying he had already been cleared by prosecutors.

Barcelona also released a statement expressing its "surprise at the difference in criteria" between the decisions by prosecutors and the state attorney's office.

"Barcelona has expressed its affection and solidarity to Leo Messi and his family in such a peculiar situation," the statement added. "The club shall continue to offer him and his family its full support and assistance in the legal, fiscal and administrative aspects of these proceedings."

A court had recently rejected an appeal filed by Messi's lawyers to drop the Barcelona player from the case. Things seemed to be going Messi's way after prosecutors this week announced their request to clear him of any irregularities, but the judge ruled Thursday there was enough evidence of crimes committed by both Messi and his father.

They are being accused of defrauding Spain's tax office of $4.6 million in unpaid taxes from 2007-09.

Messi's father made a payment of more than $5.6 million in August 2013 to cover unpaid taxes, plus interest.

A date for the trial has not yet been set.

The El Pais newspaper reported recently that Messi told authorities he would "sign anything with his eyes closed" if his father told him to do it.

The court in Gava, Barcelona, had said that although Messi was unfamiliar with tax issues, there was sufficient evidence to believe the Barcelona playmaker could have known and consented to the creation of a fictitious corporate structure to avoid paying taxes on income from his image rights. Authorities said some of the income came through companies located in tax havens.

The court had said it was not necessary for Messi "to have full knowledge of all accounting or corporate transactions or the exact amount of the fraud" for him to have had a clear idea of an intention to defraud.

Spain has recently been cracking down on tax evasion as part of its fight to repair the country's public finances after a prolonged recession triggered by the collapse of its once-booming real estate sector.

Messi's legal case is not the only one affecting Barcelona.

Spain's tax office is also investigating midfielder Javier Mascherano for taxes paid in 2011 and 2012, and a separate court in Madrid is hearing a lawsuit that accuses former Barcelona president Sandro Rosell of misappropriated funds to hide the cost of the transfer fee paid to acquire Brazil striker Neymar from Santos in 2013.

Barcelona also remains in trouble with FIFA, which handed the club a one-year ban on signing new players, through 2015, after concluding it violated rules regulating the transfer of underage players at its lauded soccer academy.