MEXICO CITY — The U.S.-Mexico relationship could change dramatically under Mexican President-elect Andres Manuel Lopez Obrador, who appears ready to put less of an emphasis on relations with the U.S. than his country’s other recent leaders and less afraid of angering his counterparts north of the border.

Lopez Obrador, who easily won the presidency in Sunday’s election and will take office in December, has rattled observers in Washington who are unsure about how he will conduct himself and Mexico’s foreign affairs.

The 64-year-old former mayor of Mexico City, a veteran leftist, has long favored a future for Mexico that is less dependent on the United States — a stark departure from numerous recent Mexican leaders who worked hand in glove with their American counterparts. His distrust of the United States is shaped in part by his experiences and in part by his read on history.

The night of President Trump’s election in 2016, Lopez Obrador wrote a message to his fellow Mexican citizens, urging them to not worry about the effect of Trump’s policies south of the Rio Grande.

“We must not forget that Mexico, by the effort and sacrifice of the fathers of our country, is a free, independent and sovereign country, not a colony, nor a protectorate,” he wrote. “It does not depend on any foreign government.”

Those patriotic musings, which he published last year in a book of essays called “Oye Trump” (Listen, Trump), offer insight into how Lopez Obrador may regard Mexico’s closest neighbor when he is sworn in Dec. 1.

“There are a lot of unanswered questions,” said Earl Anthony Wayne, a fellow at the nonpartisan Wilson Center think tank in Washington and former U.S. ambassador to Mexico.

Those include how the new president would handle renegotiation of the North American Free Trade Agreement; cooperation with the U.S. on drug trafficking and immigration; and the united front against rogue countries such as Venezuela.

“Mexican presidents have long seen their country’s future tied to the U.S., but Lopez Obrador is more skeptical,” said Andrew Selee, president of the Migration Policy Institute and the author of a recent book about U.S.-Mexico relations. “I don’t think he’s anti-American. But I think he’s distrustful of the U.S. and less invested in deepening ties with the U.S.”

Trump, who has used harsh language to describe Mexicans, telephoned Lopez Obrador on Monday to congratulate him. They spoke for half an hour, talking about trade and border security, both men’s offices said.

The State Department also reached out, saying his election demonstrated “the Mexican people’s commitment to democratic values.”

“The United States and Mexico share a lasting friendship based on strong economic, cultural and historical ties that bind our nations,” spokeswoman Heather Nauert said. The United States, she added, “looks forward to deepening our vibrant partnership.”

His opponents often sought to portray Lopez Obrador as a dyed-in-the-wool leftist in the mold of Venezuela’s Hugo Chavez or the Castros of Cuba. In reality, Lopez Obrador is more pragmatic than the more hard-core ideologues. He advocates redistribution of wealth, but he also values Mexico’s entrepreneur class and industries such as petroleum and gas exploitation.

If recent history is any indication, the first months of Lopez Obrador’s government are likely to see a Mexican cold shoulder toward the United States. When Enrique Peña Nieto was elected in 2012 to replace U.S.-friendly Felipe Calderon, he ended many of the relationships with the U.S. that had allowed U.S. and Mexican officials to work shoulder to shoulder on security and other issues.

Only after a year or so did Peña Nieto reestablish those ties. And then, after Trump was elected, the Mexican government struggled to maintain a relationship amid the insults and harsh rhetoric coming from the White House.

That was accomplished largely through a personal friendship between Mexican Foreign Secretary Luis Videgaray and Trump’s son-in-law and senior advisor Jared Kushner.

Lopez Obrador does not share such friendships with Trump’s inner circle. And that could have an effect on numerous aspects of the bilateral relationship, including the renegotiation of NAFTA.

“The Peña Nieto administration would go to great lengths to save NAFTA,” Selee said. “If President Trump wants to pull out, I don’t know how far Lopez Obrador will go to save it.”

The United States, which works closely with Mexican law enforcement on migration matters as well as its fight against drug cartels, watched Lopez Obrador’s rise warily.

Each year, the U.S. spends on average about $100 million on the Merida Initiative, a bilateral partnership forged in 2007 to help reduce the power of drug trafficking in Mexico. That money has been used to help train police, prosecutors and judges, fund improvements of prisons and jails and aid an ongoing overhaul of the criminal justice system.

At the same time, Mexico — contrary to Trump’s claims — works substantially to stop illegal immigration to the United States; it has detained nearly 150,000 Central Americans crossing Mexico en route to the U.S. in the last year and a half.

Whether Lopez Obrador will continue to cooperate with the U.S. on immigration and security issues remains to be seen.

Lopez Obrador has repeatedly said he hopes to forge a relationship “based on friendship” with the U.S. But in rallies around the country in the months leading up to his election, he also expressed his frustration with the treatment of Latino immigrants in the U.S. and the devastating effect of low-cost American agricultural imports on Mexico’s farmers.

Born to shopkeepers in Tabasco, an agrarian and oil-rich state in southern Mexico that has seen little benefit from NAFTA compared with Mexico’s north, Lopez Obrador views free-market policies and trade with the U.S. with suspicion. He believes working families have been left behind, and wants to push Mexico to be more independent in its production of food and gasoline.

He is also an amateur historian who has frequently highlighted the United States’ past aggressions against his country.

In 2016 he published a book about Catarino Garza, a Mexican revolutionary who launched a campaign into Mexico from Texas to start an uprising against the dictator Porfirio Diaz in the late 19th century. In the text, Lopez Obrador laments U.S. President James Polk’s expansionist efforts, which he calls “a Yankee invasion,” and the “tragic” loss of a large part of Mexico’s territory. He goes on to quote Mexican norteño band Los Tigres del Norte: “I didn’t cross the border, the border crossed me.”

“I think he has a read of Mexican history in which the relationship with the U.S. has not always been helpful,” Selee said. “When he looks at U.S.-Mexico history, he reads it as a history of aggressiveness.”

There are things Lopez Obrador and Trump have in common. Both are populists with strong personalities who have positioned themselves as advocates for the people in the face of the elites. Both have called for raising wages for Mexican workers.

Alfonso Romo, a busi-nessman who is one of Lopez Obrador’s top advisors, said at a news conference recently that he thinks Lopez Obrador will have the upper hand in the relationship.

“It’s very divided there,” he said of the U.S.

Lopez Obrador, on the other hand, won in a landslide, with his fledgling leftist party, known as Morena, also picking up a large number of gubernatorial and congressional seats.

“Trump doesn’t have this consensus,” Romo said.

In AMLO, as Lopez Obrador is known, Mexicans elected a strong defender of Mexico, said Jason Marczak, a Latin America expert at the Washington think tank the Atlantic Council.

“Don’t expect him to acquiesce to U.S. demands,” Marczak said.

kate.linthicum@latimes.com

tracy.wilkinson@latimes.com

Linthicum reported from Mexico City and Wilkinson from Washington.