Andrés Manuel López Obrador, who rallied voters with his battle cry against corruption and with his promises to the poor, won a resounding victory Sunday night in Mexico’s presidential election, after the concession of his two top rivals. The victory makes him the first leftist president since Mexico began its transition to multiparty democracy more than 30 years ago.

López Obrador triumphed with a party that did not exist at the time of the last election, against opponents from two parties that have ruled Mexico for nearly a century. The 64-year-old former mayor of Mexico City promises to bring his humble lifestyle and distaste for luxury to the top of a political establishment famous for self-enrichment.

An official “quick count” from a national sampling of ballots forecast that López Obrador would win with between 53 percent and 53.8 percent of the vote, according to the national electoral agency. That put him far ahead of his main opponents, Ricardo Anaya and José Antonio Meade, who conceded and offered their congratulations.

In his victory speeches, López Obrador called on Mexicans to reconcile and said his government would not be a “committee in service to a minority” but would represent all citizens rich and poor, religious or nonbelievers, migrants, “human beings of all manner of thought and all sexual preferences.”

“We will respect everyone,” he said at a downtown hotel. “But we will give preference to the most humble and forgotten.”

López Obrador’s supporters gathered by the thousands Sunday night in the Zocalo, Mexico City’s main plaza, chanting the president-elect’s name as mariachis performed. After López Obrador arrived, under a shower of confetti, he promised to increase subsidies to the elderly and disabled.

“I want to go down in history as a good president of Mexico,” he said.

But many Mexicans were dubious.

“There is so much wrong. I think some people voted for López Obrador, but the majority voted for a change that we need,” said Fernando Torres, a 23-year-old publicity agent who was walking on Paseo de la Reforma, a major downtown boulevard.

López Obrador’s victory represents an emphatic rejection of traditional politicians, whom he regularly calls the “mafia of power.” In recent decades, Mexico has been led by technocrats and pro-American politicians, while López Obrador’s role models are Mexican independence and revolutionary leaders who stood up to more powerful foreign countries.

President Trump loomed in the background of this vote. He was not a wedge issue in the election — all candidates opposed his immigration and trade policies and his anti-Mexican rhetoric — but the new Mexican president will have to manage cross-border relations that are unusually fraught.

Trump tweeted his congratulations to López Obrador on Sunday night, saying: “I look very much forward to working with him. There is much to be done that will benefit both the United States and Mexico!”

Héctor Vasconcelos, who has been floated as a possible foreign minister, said in an interview: “We are very conscious of the enormity of the challenge. But someone has to try to turn this country toward profound change.”

López Obrador’s opponents sought to portray him as a dangerous populist who would lead Mexico back to failed economic models involving subsidies and state intervention, while provoking more tension with the Trump administration.

But the unpopularity of President Enrique Peña Nieto and his Institutional Revolutionary Party (PRI) — which ruled Mexico for most of the past century — hobbled the candidate from the long-dominant party and prompted voters to search for an alternative to traditional political candidates. (Peña Nieto did not run; Mexican presidents are limited to one term.)

López Obrador’s supporters attributed his victory to the longevity and personal charisma of a candidate who was running in his third consecutive presidential election and who has campaigned in every municipality in the country. His message has remained largely consistent — eradicate corruption, invest in the poor, fight inequality — but it got a warmer reception this year because of mounting frustration after scandals in Peña Nieto’s administration and ever-growing drug-war violence.

“Voting is the only tool we have to ensure that this corrupt system changes,” said Luis Valdepeña Bastida, 51, who voted for López Obrador in Ecatepec, a densely populated city north of the capital that has high levels of crime. “The people are fed up.”

López Obrador grew up in a middle-class family in the state of Tabasco on the Gulf of Mexico and began his political career helping indigenous villagers with public works projects, which exposed him to Mexico’s glaring inequality. He broke away from the PRI in the late 1980s and joined a leftist opposition party. López Obrador gained renown as a leader of protests against voter fraud and the abuses of the state-owned oil industry.

López Obrador had only one previous electoral victory. In 2000, he became mayor of Mexico City, where he boosted social spending for single mothers, the handicapped and the elderly. Major projects, such as an elevated highway through the city and the revitalization of downtown neighborhoods, also boosted his popularity.

After two failed presidential bids, López Obrador, whose nickname is AMLO, has tempered his message this year. While he still emphasizes the fight against extreme poverty, saying it will lead to less violence and a stronger economy, he has portrayed himself as more pro-business and pro-American than in the past. His critics worry he will roll back a recent change to allow private investment in the oil industry and cancel a multibillion-dollar airport project in Mexico City.

“It’s difficult to know if he’s changed, if he’s now less radical, or if it’s just a political decision to become elected,” said Andrés Rozental, a retired Mexican diplomat. “AMLO, at least in his rhetoric, represents a shift much to the left of what we’ve ever seen nationally.”

López Obrador’s critics warn that he will be more combative toward the United States than the current president, and that the U.S.-Mexico conflict could drastically escalate if he chooses to fight with Trump. In previous years, López Obrador was a critic of the North American Free Trade Agreement, or NAFTA, but he and his team have insisted that they want to preserve it and maintain good relations with Trump.

Trump has regularly attacked Mexico for not doing enough to stop drugs, crime and undocumented immigrants from entering the United States. He has also initiated a renegotiation of NAFTA, saying Mexico has stolen U.S. jobs, and intends to build a border wall.

López Obrador, who heads the National Regeneration Movement, or Morena, says he plans to cut government personnel and salaries and prevent funds from being squandered through corruption. He intends to use those resources to boost social programs for the poor. Corruption experts express skepticism about whether this plan is realistic.

Alfonso Romo, a wealthy businessman who has been chosen as López Obrador’s chief of staff, told reporters last week that the economic team had met with hundreds of hedge funds and institutional investors as it became increasingly clear he would win.

“Up to now the markets are tranquil,” Romo said, referring to the currency, bond and stock prices. “What does that say? They have believed our plan.”

Sunday’s elections were the largest in Mexico’s history, with voters filling more than 3,200 positions at all levels of government. Among these were 628 members of the National Congress who will be able to be reelected for the first time in nearly a century, eight state governors and mayors of more than 1,500 cities, including Mexico City.

The campaign season has been marked by violence, with some 130 candidates and campaign staff assassinated across the country.

López Obrador’s Morena is hoping to capture a majority in the congress, which would be a remarkable rise for a party he founded four years ago.

“This is a historic day,” López Obrador said as he voted Sunday. “We represent the possibility of a real change, of a transformation.”

Election day began with seemingly high turnout and long lines at voting stations. There were reports that sites ran out of ballots before all those who were gathered outside could vote.

“They said it’s the biggest election ever, and they did not get enough ballots for everyone,” said Oscar Miguel Reyes Isidoro, 51, who couldn’t cast a vote in Atizapan de Zaragoza, in Mexico state.

Mexico has a long history of voter fraud, although elections have dramatically improved in recent years. In the past two elections, López Obrador has alleged fraud as a reason for his losses. Election officials insist the voting system is safe and secure.

López Obrador was competing against Anaya, an ambitious 39-year-old former president of the right-leaning National Action Party (PAN); and a 49-year-old Yale-trained economist, Meade, representing the PRI.

Maya Averbuch in Ecatepec, Mexico, and Dudley Althaus, Kevin Sieff and Gabriela Martinez in Mexico City contributed to this report.