Leftist front-runner Andrés Manuel López Obrador. (Daniel Becerril/Reuters)

CANDIDATES IN Mexico’s upcoming presidential election kicked off their campaigns Sunday, and as if on cue, President Trump took to Twitter to trash the country. Among other things, he claimed that Mexico was doing nothing to stop migrants from flowing across its southern border and on to the United States, and was “making a fortune on NAFTA.” His accusations were ignorant and false, and though they probably weren’t aimed at Mexican politicians or their voters, they may enhance the already strong possibility that the July 1 ballot will be won by a left-wing populist who is as hostile to free trade and close U.S.-Mexican relations as is Mr. Trump.

Andrés Manuel López Obrador, who has taken a commanding lead in polls over two more-centrist challengers, just happens to be the candidate who has pushed back most strongly against the abuse Mr. Trump has aimed at Mexicans. In his opening speech Sunday, Mr. López Obrador vowed that “neither Mexico nor its people will be treated like a piñata by any foreign government,” adding that Mr. Trump’s “foreign policy . . . and contemptuous attitude toward Mexicans are wrong.”

Of course, if Mexicans choose Mr. López Obrador, the main reasons will be domestic. In that domain, the rhetoric of the former Mexico City mayor is similar to that of Mr. Trump. Mr. López Obrador rails against the “economy of the elite,” promises to battle entrenched corruption and complains about reforms that have opened Mexico to international competition. He deftly exploits the failures of the liberal-minded outgoing president, Enrique Peña Nieto, whose reforms have so far failed to deliver the economic growth he promised as his administration has been plagued by scandal. The violence racking parts of the country heightens the public’s appetite for change.

Like Mr. Trump, Mr. López Obrador seemingly would like to lead his country back to an earlier time — in his case, the statist Mexico of the 1970s. He rivals the U.S. president in his disregard for the North American Free Trade Agreement, of which he says, “The few benefits have come at an extremely high cost.” He’s opposed to a deal revising the agreement before the election, though that is what the Trump administration is reportedly aiming for.

Mexicans who warn that Mr. López Obrador would lead Mexico to a catastrophe resembling Hugo Chávez’s Venezuela are probably wrong. Having lost two previous presidential elections, he has shifted toward the center, at least rhetorically, and would probably fail if he tried to dismantle democratic institutions; the National Congress would remain under the control of rival parties.

It nevertheless is starting to look probable that, after a quarter-century of steady improvement, U.S.-Mexican relations will be in the hands of dueling populists who will see political advantage in trashing them. That, of course, would simply worsen the problems the two demagogues decry, from drug and gun trafficking across the border to illegal immigration. But perhaps Mr. Trump would welcome more opportunity to rally his base against supposed Mexican perfidy. If current trends continue, some of his tweets might even come true.