The 25-year-old Argentina forward and his father, Jorge Horacio, are suspected of filing fraudulent tax returns for 2007-09, officials say.
The World Player of the Year expressed his surprise, denying the allegation.
His Barcelona net salary is said to be some 16m euros a year, making him one of the world’s highest-paid athletes, accordingtoBBC.
He has also signed a number of multimillion-dollar endorsements with major sponsors around the globe.
On Wednesday, a complaint signed by prosecutor Raquel Amado was filed at the courthouse in Gava – the affluent Barcelona district where Messi lives.
Judges at the courthouse must accept the complaint before the suspects can be charged, reports say.
In financial terms, 4m euros in the world of Lionel Messi is not a huge amount. According to Forbes, the Barcelona star currently earns more than 15m euros a year from his salary and prize money.
When you add in his earnings from sponsorship and the rights to his image, Forbes puts his total annual net income at more than 31m euros.
Messi is worshipped by Argentina and Barcelona football fans and admired all over the world for his ability on the pitch, and his humility off it. However the allegation the footballer and his father failed to declare millions of euros of income – while people in Spain, in general, pay more tax and often earn less, or don’t have a job at all because of the economic crisis – is making headlines all over the Spanish media.
Messi and his father deny any wrongdoing, he still hasn’t been charged and it could be a while until we know whether he will be because the legal system in Spain is notoriously slow moving. But despite all that, the scandal raises difficult questions, and the image of Lionel Messi could be damaged.
The player and his father are accused of three crimes of defrauding the state of taxes related to income from the use of his image.
They are suspected of using companies abroad – in Belize and Uruguay – to sell the rights to use the image.
The accusation is that with the help of firms based outside Spain, where he lives and plays club football, Messi and his father avoided paying more than 4m euros in tax.
If convicted, Messi could face up to six years in prison and a large fine, according to Spain’s EFE news agency.
Responding to the allegations, Messi expressed his surprise, saying he had only learned about the investigation against him through the media.
He wrote on his Facebook page: “We have never committed any infringement. We have always fulfilled all our tax obligations, following the advices of our tax consultants who will take care of clarifying this situation.”
Argentina’s media also appeared puzzled by Wednesday’s development, with the Clarin newspaper describing it as “unexpected news”.
Barcelona FC have not commented on the allegations.
The investigation comes as the Spanish authorities step up their efforts to clamp down on tax fraud, as the government tries to balance its budget during a continuing economic crisis, the BBC’s Tom Burridge in Madrid reports.