Claudia Sheinbaum makes history as the first female president of Mexico

Claudia Sheinbaum was elected the first female president of Mexico.

It went down in history as a country plagued by widespread criminal and gender-based violence.

Crowds of flag-waving supporters sang and danced to mariachi music in Mexico City's main square, celebrating the victory of the ruling party's candidate.

The 61-year-old former mayor of Mexico City, a scientist by training, won about 58-60 per cent of the vote, the National Electoral Institute said after a quick count.

That's more than 30 percentage points more than her main opposition rival Xochitl Gálvez, and about 50 percentage points more than the only male candidate, longtime centrist Jorge Alvarez Maynez.

Voters flocked to polling stations across the Latin American country despite sporadic violence in areas terrorized by ultra-powerful drug cartels.

Thousands of soldiers were deployed to protect voters after a particularly bloody election process in which dozens of local politicians were killed.

Sheinbaum earlier hailed what he called a "historic" election day.

After casting her ballot, she revealed that she had not voted for herself, but for 93-year-old left-wing veteran Ifigenia Martinez in recognition of her struggle.

"Long live democracy!" Sheinbaum said.

After the polls closed, Gálvez urged his followers to closely monitor the vote count.

"We are competing against authoritarianism and power, and they are capable of anything," said the 61-year-old indigenous senator and businesswoman.

"I won't let you down," Claudia Sheinbaum promised.

"I will become the first female president of Mexico," she added to her supporters, announcing that her party, the Movement for National Renewal (Morena), had won a "qualified majority" in Congress. | BGNES