Donald Trump’s path to the Presidency as an outsider always implied on-the-job-training. This week’s lesson: The world is not a Republican primary. President Trump’s Twitter broadsides against Mexico have unleashed a political backlash that has now become a diplomatic crisis with a friendly neighbor.

Mr. Trump fancies himself a negotiating wizard, but in this case he is out-negotiating himself. The White House announced last weekend that Mr. Trump had asked Mexican President Enrique Peña Nieto to Washington to talk about trade, immigration and the border. Despite Mr. Trump’s many slights against Mexico during the campaign, Mr. Peña Nieto accepted.

Mr. Trump proceeded to roll out the red carpet by announcing his plan to build “the wall” on the U.S. southern border that Mexicans of all political stripes consider an insult. On Wednesday he also rolled out press secretary Sean Spicer to aver that “one way or another, as the President has said before, Mexico will pay for it.”

That cornered the Mexican President, who represents a nation unified by Mr. Trump’s anti-Mexico rhetoric. Late Wednesday Mr. Peña Nieto delivered a short national address repeating that Mexico won’t pay for the wall. The Mexican government also let slip that he might cancel his Washington visit.

On Thursday morning Mr. Trump tweeted “if Mexico is unwilling to pay for the badly needed wall, then it would be better to cancel the upcoming meeting.” Mr. Peña Nieto cancelled. Later Thursday Mr. Spicer added confusion with some comments about a border fee as part of tax reform. Chief of Staff Reince Priebus tried to walk that back, but this is amateur hour.