MEXICO CITY— Claudia Sheinbaum , the former mayor of Mexico City, will become Mexico’s first female president after romping to victory in an election billed as a referendum on the leftist policies of departing President  Andrés Manuel López Obrador.

Sheinbaum, the candidate of the ruling Movement of National Regeneration, known as Morena, won with an estimated 58.3% to 60.7% of the vote, according to a quick count based on a sample of voting stations released by Mexico’s election agency.

Claudia Sheinbaum and MORENA party winner for Mexico City mayor Clara Brugada gesture to supporters after Sheinbaum was declared the winner of the presidential election according to the INE electoral institute’s rapid sample count, in the Zocalo plaza in Mexico City, Mexico June 3, 2024. REUTERS/Daniel Becerril

Her closest rival, Xóchitl Gálvez , the candidate of a coalition of three opposition parties, tallied between 26.6% and 28.6% of the vote. She conceded defeat.  Jorge Álvarez Máynez from the center-left Citizen Movement garnered from 9.9% to 10.8% of the vote. Final results were expected early on Monday. Pre-election polls gave Sheinbaum a lead of around 20 points.

A child holds on to a voting booth as its mother and other Raramuri Indigenous people vote at a polling station during Mexico’s general election, in Norogachi, in the state of Chihuahua, Mexico, June 2, 2024. The writing on the booth reads “The vote is free and secret.” REUTERS/Jose Luis Gonzalez

Raramuri women wait to vote at a polling station on the day of the general elections, in the town of Norogachi, in the state of Chihuahua, Mexico, June 2, 2024. REUTERS/Jose Luis Gonzalez TPX IMAGES OF THE DAY

The  vote reflected support  for the government of López Obrador, who since taking office in 2018 redirected spending to welfare programs and has maintained approval ratings above 60%. He also imposed austerity measures on the federal government after campaigning on an anticorruption platform. López Obrador won the presidency six years ago with more than 53% of the vote.

Morena also appeared headed for a two-thirds majority in congress needed to make constitutional changes without opposition support. That could allow the passage of unfinished key projects of López Obrador, who wanted to overhaul energy laws, the judiciary and the election agency. Mexican law doesn’t allow for presidential re-election.

Sheinbaum sought to address concerns of weakening checks and balances because of her crushing victory. “We are democrats and out of conviction would never be an authoritarian or repressive government,” she said, speaking to a cheering crowd in central Mexico City. In her victory speech, she said her administration would respect private investment, and keep fiscal discipline and central bank independence.

Although Sheinbaum’s victory speech was conciliatory, Mexico could face difficult times if Morena pushes through constitutional changes that eliminate judicial independence, among other initiatives that opponents say would erode checks on executive power. “This is the worst scenario that could have happened,” said Carlos Elizondo, a professor of government at the Tecnológico de Monterrey university.

Mexico’s peso was down 1.05% to 17.20 per dollar in after-hours trading.

Sheinbaum said Mexico will have friendly and mutually respectful relations with the U.S. “We’ll always defend Mexicans who are on the other side of the border,” she told supporters.

Exit polls showed Morena on track to win at least six gubernatorial races, including the Mexico City mayor’s office.

People queue to cast their vote at a polling station on the day of general elections, in San Juan Chamula, Mexico, June 2, 2024. REUTERS/Jacob Garcia

Sheinbaum, who is due to take office on Oct. 1, will also become the first Jewish head of state in one of the world’s largest Catholic countries. Mexico’s political system is secular and her Jewish background hadn’t been a factor in the election.

“Imagine, after 200 years a woman will now govern our country. Only 70 years ago we didn’t even have the right to vote,” said María Antonieta Olaya, a sociologist who was among the hundreds of people celebrating Sheinbaum’s victory in the historic district of the capital.

Sheinbaum, a 61-year-old energy engineer whose Jewish grandparents emigrated to Mexico fleeing persecution in Eastern Europe before World War II, has served López Obrador faithfully for decades. She was the former president’s environmental chief when López Obrador was mayor of Mexico City. Sheinbaum was elected mayor in 2018.

“She owes her election to López Obrador’s support,” said Michael Shifter , a former president of the Inter-American Dialogue, a Washington-based think tank. “They have different backgrounds and styles, but I don’t see much daylight between them.”

Sheinbaum’s presidential run benefited from López Obrador’s populist appeal and high approval ratings, as well as economic factors such as a robust labor market, strong currency, hefty minimum-wage increases and the broadening of the social safety net, said  Goldman Sachs ’s chief Latin America economist Alberto Ramos .

The U.S. will be looking to Mexico’s president-elect for cooperation in  stemming the flow of migrants to its southwest border, and to tackle the fentanyl crisis , said Duncan Wood, a senior adviser to the Wilson Center, a Washington think tank. After lowering homicide rates in Mexico City by half, Sheinbaum has pledged to replicate such results across Mexico, which is plagued by killings, forced disappearances and massive extortion by  more than 200 organized crime gangs .

The incoming administration will also have to deal with the review of the U.S.-Mexico-Canada Agreement due in 2026. The U.S. and Mexico have had disputes over agriculture and energy after López Obrador c hanged laws that affected U.S. companies  with investment in Mexico, and ordered a ban on genetically modified corn  that would affect U.S. exporters .

Economists expect that manufacturing will take on a bigger role in the negotiations, as Mexico holds an important position in terms of nearshoring and the role that China is playing in global trade.

“Mexico is probably more important than ever before in terms of being an economic partner,” Wood said. Sheinbaum has said that she wants to ensure that the  U.S.-Mexico-Canada Agreement  becomes one of the main pillars for Mexico’s development.

Mexico’s policy of cooperating with the U.S. on migration issues won’t radically change in a Sheinbaum presidency, said Andrew Selee , president of the Migration Policy Institute, a Washington-based think tank. She is likely to play a more prominent regional role by negotiating migration agreements with other Latin American countries as well as the U.S. But much will depend on her ability to negotiate with the U.S. López Obrador was a pragmatist who was able to cut deals with the U.S. Sheinbaum’s political skills are unknown, he said.

Her biggest challenge may be dealing with former President Donald Trump , should he win a second term. “With Trump, it’s unpredictable,” said Earl Anthony Wayne, a former U.S. ambassador to Mexico. “Managing the relationship with the U.S. becomes much harder.”

During his presidency, Trump threatened to place tariffs on Mexican exports if the country didn’t stop migrants from going to the U.S., prompting Mexico to deploy thousands of National Guard personnel to contain the migrant flow. He also forced Mexico into renegotiating the 1994 North American Free Trade Agreement, which resulted in the current USMCA.

On the domestic front, Sheinbaum vowed to continue with López Obrador´s popular social welfare programs, with the state guiding the economy in favor of the poor. These include bimonthly cash handouts of about $350 for the elderly, monthly scholarships of about $50 for students and reforestation grants in rural areas.

The welfare programs helped pull José Luis Zambrano ’s grandparents, parents, uncle and aunt out of severe poverty. “They had nothing,” said Zambrano, a 21-year-old private security guard at a Mexico City liquor store who said he would vote for Sheinbaum. “Thanks to that support, they can now live a more normal life.”

Nearly 100 million Mexicans were eligible to vote in Sunday’s election held amid a  public security crisis  and a high degree of political polarization. Voters also elected a new Congress, nine gubernatorial posts and thousands of state and municipal officials.

The vote was peaceful, with just a handful of scattered incidents, electoral authorities said. Mexicans voted at more than 170,000 polling stations staffed by trained citizens. Electoral authorities said that 222 polling stations, most in the violence-stricken states of Michoacán and Chiapas, didn’t open for security reasons.

Both leading candidates shared one priority: to tackle the  powerful criminal organizations  that control U.S.-bound drug and migrant smuggling routes and extort hundreds of thousands of businesses across Mexico.

Security was top of mind for most Mexican voters. The growing power of Mexico’s criminal gangs is blamed for making this election the most violent in the country’s modern history. More than 200 candidates, public officers and politicians have been killed since the start of the electoral process in September.

López Obrador, a divisive leader who has reshaped Mexican politics, has said he would retire to his home in southern Mexico when his term ends Sept. 30. He plans to undertake a farewell journey soon through the country to thank voters in the coming months.

In her closing rally Wednesday at Mexico City’s historic Zocalo square, Sheinbaum told her supporters—and perhaps her mentor—that his place in history was assured.

“I promise to protect López Obrador’s legacy,” she said.

Write to José de Córdoba at jose.decordoba@wsj.com and Anthony Harrup at anthony.harrup@wsj.com