(CNN) -- Mexican President Felipe Calderon's ruling party paid the price for a weak economy in midterm elections as the opposition Revolutionary Institutional Party rolled to victories in the lower legislative house as well as state and local posts.
Mexican President Felipe Calderon wasn't on Sunday's ballot and has three years left in his six-year term.
With more than 99 percent of the votes counted, the PRI had 36.7 percent to 28 percent for Calderon's National Action Party (PAN), the state-run Notimex news agency reported Monday.
The leftist Party of the Democratic Revolution (PRD), which nearly won the 2006 presidential election, came in a distant third with 12.2 percent of the vote.
In response to the defeat, PAN president German Martinez resigned from the top party post Monday.
On the ballot were seats for 500 federal legislators, six governors and about 500 mayors and local legislators in 11 states. Though Calderon has three years left in his six-year term and was not on the ballot, analysts said Monday he was held responsible for Mexico's problems amid the global economic downturn.
"He got a beating because of the economy," said Ana Maria Salazar, a television and radio political commentator in Mexico City.
"The government in power pays for it," said Peter Hakim, president of the Washington-based Inter-American Dialogue.
Besides the economy, Calderon has had to face the consequences of a drug war he launched that has left more than 10,000 people dead since he came to office in December 2006.
He also had to deal with the H1N1 flu pandemic that first became known in Mexico this year.
The PAN has the most seats in the Senate and the Chamber of Deputies, the lower house of Mexico's Congress, but it does not have a majority in either. The party lost its lead in the lower house, as the PRI will hold more seats when the new delegates are seated in December. No seats were at stake in the Senate, which elects its members every six years.
Calderon acknowledged the setback in a late-night address to the nation Sunday.
"The federal government recognizes the new composition of the Chamber of Deputies since it is a sovereign decision of the citizens. I congratulate who they have chosen," Calderon said, adding he will work with the new representatives.
He will have no choice but to work with the resurgent PRI, analysts said. But since the PAN did not have control of either house of Congress, Calderon has been compromising and making deals with the PRI and other parties since coming to power.
"I don't think the job is much more difficult than it was at the outset," Hakim said. "It's all a matter of degrees. Yeah, it will make it a little more difficult. But he has had to work through negotiation anyway."
Still, analysts said, the PRI now wields considerable more power.
"They're in a position to run Congress," said Andrew Selee, director of the Woodrow Wilson Center's Mexico Institute.
By forming temporary coalitions with the Green Party and other minor parties, the PRI can block presidential vetoes, Salazar said.
"They pretty much have control over the purse," she said.
Much more is at stake for the PRI though. After having held the presidency from 1929 to 2000 and then losing it to the PAN in the last two elections, the party is looking for a path back to power. Sunday's results were particularly significant because the PRI finished third in the 2006 presidential election.
"The presidential campaign has started as of today, Monday," Salazar said.
Also significant was the PRD's apparent collapse as a major party, considering it came within 1 percent of winning the presidency in 2006.
That race was so close that the results were not verified until a controversial decision two months later. Losing candidate Andres Manuel Lopez Obrador refused to accept the results and announced himself the winner. Fistfights broke out in the Chamber of Deputies.
The PRI drew away votes from the PRD in Sunday's election, Hakim said, noting that may help Calderon because the PRD is Calderon's main foe in Congress. Working with a larger PRI may be easier.
But Selee said Calderon is on a deadline, until the 2012 presidential race really heats up.
"His window of opportunity is for the next year and half," Selee said. "The PRI wants to show that they can lead, that they're a party of ideas."
No one knows if the PRI is up to the task.
"The big question is whether the PRI will look forward only to the presidential elections," Hakim said. "The PRI has to show that they're responsible and capable of governing again."
To do so, the PRI has to make sure that internal fighting over who will run as the presidential candidate in three years does not paralyze the party.
"Don't underestimate the ability of the PRI to cannibalize itself," Salazar said.
PRI leader Beatriz Paredes has emerged as a major power broker. As head of the party and newly elected member of the Chamber of Deputies, she will lead the PRI's legislative efforts. That's good for Calderon, Salazar said, because it will be "much easier to negotiate with her than with other factions of the PRI."
But if the PAN and PRI can't agree, Selee said, "there will be a breakdown of consensus politics."
Mexico's leaders -- regardless of party affiliation -- also have to battle apparent disenchantment among everyday Mexicans.
Voter participation Sunday was about 30 percent, officials said, but more 5 percent of those were people who "annulled" their ballots. They turned in a ballot but did not vote for anyone or defaced the ballot. Their intent was to show that they cared enough to vote, just not for anyone on the ballot.
"It's a repudiation of what is going on in Mexico in general," Salazar said.
Selee sees "a general skepticism," saying, "Mexicans have tired of where things are going."