The presidential election is the first since Vicente Fox's stunning victory in 2000 ended 71 years of rule by the Institutional Revolutionary Party, or PRI. It will determine whether Mexico becomes the latest Latin American country to move to the left.
Polls predict a close race between conservative Felipe Calderon of Fox's party and leftist Andres Manuel Lopez Obrador, a former Mexico City mayor. The PRI's Roberto Madrazo was running a distant third, ahead of two minor candidates.
Also being elected were five governors and both houses of Congress.
Accompanied by his two children, Lopez Obrador showed up shortly before the polls opened at 8 a.m. local time to cast his vote inside a house in his middle class Mexico City neighborhood. Surrounded by throngs of journalists, Lopez Obrador did not comment publicly.
Waiting in the line was Armando Juarez, 46, a high school teacher, who said he would vote for Lopez Obrador, who has promised to govern for the poor first.
"I believe he represents hope, especially for people with low salaries who are looking for a more egalitarian country," Juarez said.
Officials hoped to announce a winner within hours of the 8 p.m. (0100 GMT) closing of the last poll, based on a quick count. But they cautioned they would wait if the race was too close.
The election capped months of mudslinging and angry rhetoric that laid bare a broad divide between Mexico's rich and poor. Lopez Obrador accused Calderon of catering to the rich, while Calderon warned that Lopez Obrador would put at risk the low-interest loans and other gains that helped swell the middle class during Fox's tenure.
Calderon compared Lopez Obrador to Venezuela's radical President Hugo Chavez, but Lopez Obrador named a conservative economic team that reassured investors, even as he spent his campaign reaching out to the 50 million Mexicans who scrape by on a few dollars a day.
As he launched his campaign in a dusty mountain town with the lowest standard of living in Mexico, Lopez Obrador promised: "I'm going to listen to everyone. I'm going to respect everyone. But the poor and forgotten of Mexico will get preferential treatment."
Calderon promised to be the "jobs president" and distanced himself from Fox even as he pledged to stay the course of economic stability.
Madrazo painted himself as the alternate to the "radical left and intolerant right." But many questioned how long his party, which suffered infighting and defections during the campaign, would survive past the election.
Mexican law limits presidents to one term, and Fox plans to retire to his ranch in December after his replacement is sworn in. He was casting his vote at a school near the presidential residence.
All three candidates promised to strengthen relations with the United States while opposing increased border security measures unpopular in Mexico, including building more border walls and the deployment of National Guard troops.
The estimated 10 million Mexicans living in the United States were allowed to vote from abroad for the first time, but the 41,000 ballots they requested weren't likely to make much of a difference. The effort, thrown together late last year to beat electoral deadlines, wasn't well publicized in the United States.
Thousands of those who missed out were heading south Sunday to cast votes at ballot centers set up along the border.
Here are the positions of the three main candidates in Mexico's presidential election on issues of importance to the United States:
TRADE AND ECONOMY