Ruling-party candidate Claudia Sheinbaum (L) and opposition hopeful Xochitl Galvez are leading Mexico's presidential race
AFP

A gunman shot dead an aspiring mayor at a rally Wednesday in southern Mexico, marking a bloody end to campaigning in a country expected to elect its first woman president this weekend.

More than 20 people running for local office have been murdered during what has been a particularly violent election season in the Latin American nation, according to an official count.

The latest victim was Alfredo Cabrera, a mayoral candidate for an opposition coalition who was gunned down in the southern state of Guerrero, causing chaos and panic among people attending the rally.

Barring a major upset, a woman appears almost certain to be elected leader of the world's most populous Spanish-speaking country when millions of Mexicans vote on Sunday.

"We're going to make history," ruling-party candidate Claudia Sheinbaum, who is leading in polls, told a cheering crowd at her closing campaign rally in Mexico City's main square.

"I say to the young women, to all the women of Mexico -- colleagues, friends, sisters, daughters, mothers and grandmothers -- you are not alone," the 61-year-old said.

Sheinbaum has pledged to continue outgoing left-wing President Andres Manuel Lopez Obrador's social programs and strategy of tackling crime at its roots -- a controversial strategy that he calls "hugs not bullets."

Opposition presidential candidate Xochitl Galvez, also 61, promised a tougher approach to dealing with drug cartel-related violence at her closing rally in the northern city of Monterrey.

"You will have the bravest president, a president who does confront crime," she said.

Galvez accused Lopez Obrador of implementing "a security strategy where hugs have been for criminals and bullets for citizens."

Criminal violence that has left more than 450,000 people dead since 2006 will be among the major challenges facing Mexico's next leader, along with managing migration and delicate relations with the neighboring United States.

Sheinbaum, a former Mexico City mayor and a scientist by training, is the clear front-runner in the presidential race with 53 percent of voter support, according to a poll average from research firm Oraculus.

Galvez, a center-right senator and businesswoman with Indigenous roots, is second with 36 percent.

The only man running -- long-shot centrist Jorge Alvarez Maynez -- has 11 percent.

Thousands of Sheinbaum's supporters massed Wednesday to hear her speak, with many wearing purple -- the color of the ruling Morena party.

"The people have woken up. We don't want the old governments to rob us anymore because the poor come first," said Soledad Hernandez, a 23-year-old housewife from the southern state of Oaxaca.

Sheinbaum owes much of her popularity to Lopez Obrador, widely known as AMLO -- a close ally who has an approval rating of more than 60 percent but is only allowed to serve one term.

"People from the countryside had nothing and now they're better off with AMLO," said Maria Isabel Zacarias, 55, a street food seller who came from the south to hear Sheinbaum speak.

Bertha Diaz, a 71-year-old Galvez supporter, said she feared that if Sheinbaum wins, "it will be more of the same like with Lopez Obrador, who has sunk Mexico and wants to turn it into another Venezuela."

Nearly 100 million people are registered to vote for president, members of Congress, several state governors and local officials, in the biggest-ever elections in the country of 129 million.

Around 27,000 soldiers and National Guard members will be deployed to reinforce security on election day.

Security Minister Rosa Icela Rodriguez said Tuesday that 22 people running for local office had been murdered since September.

Some non-governmental organizations have reported an even higher number, including Data Civica, which has counted around 30 killings of candidates.

The PRI, one of the opposition coalition parties, accused the government of having "not made even the slightest effort to guarantee the safety of the candidates."