ONE week ago, the idea that the president of Mexico would share a dais with the Republican presidential nominee would have seemed absurd. And yet on August 31st Donald Trump, the scourge of Mexico, briefly visited the country to discuss bilateral relations with Enrique Peña Nieto—a man who back in March compared the American’s rhetoric to that of Hitler and Mussolini. After their hour-long meeting, both men were keen to talk up the closeness of the Mexican-American relationship, referring to the 6m American jobs that depend on trade with Mexico, the 40 cents of American-made product in every dollar of goods that Mexico exports there, and the one million daily border crossings. Some familiar themes were aired. Mr Trump reiterated his opposition to the North Atlantic Free Trade Agreement for being “of far greater benefit to Mexico than to the United States”. Mr Peña, in a nod to Mr Trump’s plans to deport illegal immigrants, reiterated how the job of the Mexican president was to defend the interests of Mexicans “wherever they are”. In response to a question from a reporter, Mr Trump said the two had not discussed who would pay for his proposed border wall. Mr Peña later contradicted him, tweeting that he “had made it clear Mexico will not pay for the wall”.

The invitation to Mr Trump was delivered on August 26th (along with one to Hillary Clinton). Delighted, no doubt, by the chance to stand shoulder-to-shoulder with a world leader, Mr Trump accepted with alacrity. He asked to meet Mr Peña ahead of a big speech on immigration in Arizona the same day. The timing may not have suited Mr Peña, who is due to deliver his state-of-the-nation report on September 1st, but a meeting with Mr Trump seems to have been a diary-clearing event.

The invitation proved hugely controversial in Mexico. What, many people wondered, did it take to be removed from their president’s guest list? Mr Trump, after all, has accused Mexicans of bringing drugs and crime into America and of being rapists. Opinions of the Republican nominee south of the Rio Grande vary from the poor to the awful. In June, just 2% of Mexicans said they wanted Mr Trump to be the next president; 74% were rooting for Mrs Clinton. Responses to his imminent arrival were widely vituperative. Margarita Zavala, one of the leading contenders for the presidential nomination of the opposition National Action Party in 2018, tweeted: “Although they have invited him, he should know that he is not welcome.” Another opposition party, the Party of the Democratic Revolution, questioned the rationale behind the meeting, saying it “only favours the political aspirations of this anti-Mexican demagogue”.

Given the depth of feeling towards Mr Trump, the invitation has baffled many. But Mr Peña’s approval rating is languishing at just 23%, the lowest of his term. On the domestic front he has problems with rising murder rates, recalcitrant teachers, a potential credit downgrade and another nasty human-rights abuse. His team may have dreamed up the invitation as a way of making him seem more statesmanlike through the gracious extension of an olive branch. He himself spoke of the importance of “dialogue”.

Mr Peña may also have decided that, despite the Republican candidate’s position in the polls, the time has come to prepare more seriously for his possible presidency. “This is a classic Mexican strategy to try to minimise potential harm,” says Duncan Wood, head of the Mexico Institute of the Woodrow Wilson Centre in Washington, DC. By opening a channel of communication at this stage, goes the theory, discussions become easier in the event of a Trump victory. (Mr Trump made a note of calling Mr Peña his “friend” afterwards.) In the same vein, the development of a relationship now could dampen some of the volatility that would be expected in the peso exchange rate should the NAFTA-bashing Mr Trump win.

The president’s performance after the meeting is unlikely to have won round Mexican doubters. He was as polished as ever, but in his failure to take Mr Trump more vigorously to task for some of his previous comments vis-à-vis Mexico—even to request an apology—he disappointed. Not for the first time, the Mexican administration stands accused of misunderstanding the way the people of the country think. The decision to speak to Mr Trump may be defended as a move that put Mexico’s relationship-building needs ahead of the president’s personal popularity. But the danger for Mr Peña is that by giving Mr Trump a platform from which to appear presidential, he increases the chances of a Republican victory in November. And that is something Mexico is desperate to avoid.