The mayor of top Mexican tourist resort Cancun was charged with drug trafficking links today.
Gregorio Sanchez faced charges of organised crime and money laundering a week after he was arrested.
Prosecutors say he protected two of Mexico's most brutal drug gangs and lived beyond his means.
The formal charges bar Sanchez from participating in politics, ending his run for governor of the coastal state of Quintana Roo.
Officials have said they cannot remember another Mexican election candidate ever being charged with drug ties in the middle of a campaign, and leaders of Sanchez's party say the allegations are politically motivated.
The July 4 elections in 10 Mexican states have already been marred by attacks and threats against candidates, fuelling fears that Mexico's powerful drug cartels are increasingly infiltrating politics through bribes and intimidation.
One candidate for mayor of a northern town near the border with Texas was shot dead inside his business after ignoring warnings to drop out of the race.
Judge Carlos Elorza said prosecutors have submitted testimony and documents indicating that Sanchez was using illegally obtained funds and had ties to the Beltran Leyva and Zetas cartels.
The Attorney General's Office has said the evidence includes several protected witnesses and documents from the Finance Department showing that Sanchez made bank withdrawals amounting to more than $2m (€1.62m), a sum that does not correspond to his declared income.
Sanchez's Democratic Revolutionary Party says the mayor has a property business that explains his wealth. It has compared the case to last year's arrest of 12 mayors in the western state of Michoacan on drug charges just two months before state and congressional elections.
All but two have since been released for lack of evidence, feeding allegations that their arrests had been a political manoeuvre to bolster the government's tough image ahead of elections.
Corruption scandals are nothing new in Cancun, whose white-sand beaches and raucous nightclubs make it a popular holiday destination.
Former Quintana Roo governor Mario Villanueva was extradited last month to the US to face charges of conspiring to import hundreds of tons of cocaine through Cancun.
Last year, Sanchez's police chief and other close collaborators were arrested for allegedly protecting cartels.
The police chief was also questioned in the murder of an army general hired to root out police corruption in the city.