WASHINGTON – The scene in the Oval Office was remarkable: The foreign minister of Mexico — the very country that Donald Trump had turned into a campaign-trail piñata — huddled with now-President Trump and his son-in-law, Jared Kushner.

The men were debating what Trump would say in a speech later that day as he ordered construction of a wall at the U.S.-Mexico border. The Mexican diplomat, Luis Videgaray, and Kushner, a White House senior adviser, had concluded that the remarks as drafted would upend the two countries' fragile relationship, so together they urged Trump to soften his language about Mexico.

The trio arrived at a compromise: Trump, understanding that Mexicans would hang on his every word, agreed to state that a strong Mexico was also in the best interests of the United States. In Mexico City that afternoon, Jan. 25, officials welcomed Trump's remarks as the most encouraging statement he had given to date about Mexico — and they celebrated Kushner as a moderating influence.

Relations ruptured anew only hours later, however, after a war of words between Trump and Mexican President Enrique Peña Nieto — punctuated by an angry Twitter missive from Trump the next morning while Videgaray was back at the White House.

Trump promised a foreign policy based on unpredictability, and by that measure he is delivering. The messy encounter with a traditional ally — which was detailed in interviews with a half dozen U.S. and Mexican officials — encapsulates his administration's emerging foreign policy, one that mingles the president's public bellicosity with Kushner's behind-the-scenes diplomacy.

Kushner, 36, has no traditional foreign policy experience, yet has become the primary point of contact for presidents, ministers and ambassadors from more than two dozen countries, helping lay the groundwork for deals. His influence extends throughout the Americas, Europe, the Middle East and the Asia Pacific.

Kushner's back-channel communications with Mexico — the full extent of which has not been previously reported — reveal him to be almost a shadow secretary of state, operating outside the boundaries of the State Department or National Security Council.

Videgaray had come to the White House on Jan. 25 for a full day of private meetings, but it was Kushner who gave him a heads up that Trump would deliver a speech that afternoon at the Department of Homeland Security where he would sign an executive order on his signature border wall.

And it was Kushner who led Videgaray into the Oval Office for an unscheduled audience with the president, where together they made their case to Trump for a more measured discussion of Mexico.

The president agreed.

"We also understand that a strong and healthy economy in Mexico is very good for the United States — very, very good," Trump said in his speech. "I truly believe we can enhance the relation between our two nations to a degree not seen before, certainly in a very, very long time."

But Videgaray and Kushner's victory was short lived. So strong were the anti-Trump political winds at home that Peña Nieto felt compelled to go on television that night to declare that Mexico would never pay for the border wall.

This angered Trump, who tweeted at 8:55 Eastern time the next morning that he and Peña Nieto should cancel their upcoming summit if Mexico refuses to pay for the wall. Peña Nieto called off the visit and in a brief phone call instructed Videgaray — back at the White House for another round of meetings — to leave and come home.

The mission was aborted, and Kushner seethed with frustration.

Some of the leaders who have dealt with Kushner said they were initially skeptical but found him to be a good listener and courteous intermediary who quickly intuits the core of their issues and can facilitate meetings throughout the administration.

One of his top ambitions is to help broker peace in the Middle East — something with which the president has publicly tasked him — and Kushner, an Orthodox Jew, quietly has taken an active role in helping select ambassadors to that region.

"Everyone is trying to get to know Jared Kushner," said the ambassador from one U.S. ally, who spoke on the condition of anonymity to be candid. Many ambassadors were loathe to put even their positive thoughts about Kushner on the record for fear of jeopardizing what has become their most important contact in Trump's Washington.

Kushner's role as a foreign policy fixer is, on the surface, an unlikely one. He came of age as the oldest son in a Democratic real estate family, and as a young man initially divided his attentions between his family's business and the New York society newspaper he purchased in 2006.

In Trump's inner circle, Kushner draws plaudits for smoothing feathers ruffled by his father-in-law's more erratic moves — with some aides bemoaning that on Saturdays, when Kushner observes Shabbat and does not work or use electronic devices, the workings of the White House sometimes devolve.

Still, the president risks undermining Kushner's best efforts with his erratic compulsions, short attention span and tendency to lash out at real or perceived slights, as happened in the case of Mexico.

"Our relationship with Mexico continues to grow stronger," White House press secretary Sean Spicer said. "They're excited to pursue both economic and security areas of interest and we continue to have a very, very healthy bilateral relationship."

In the Mexico talks, the relationship between Kushner and Videgaray, who met through friends in the financial world, has proved pivotal, especially for Mexico. They have forged a personal bond and helped bring together Trump and Peña Nieto, whose public positions and rhetoric are at extreme odds.

Kushner has inquired about books and articles on the history of U.S.-Mexico relations, and Mexican officials said Kushner offers Trump a different perspective from the one the president has formed based on his opposition to illegal immigration and trade deals he considers unfair to U.S. workers.

"Videgaray has in his favor a close relationship with Jared, and that opens a direct channel of communication with Trump," said Rafael Fernandez de Castro, a professor at ITAM university in Mexico City. Though he added, "The son-in-law is not going to save us."

There appear to be limits to Kushner's influence. The leaders of both countries are at a stalemate, not only over the border wall but also over trade, with Mexico trying to preserve the North American Free Trade Agreement that Trump campaigned against. Further complicating the relationship are domestic political pressures.

"The president of the United States is speaking to his issues and his base, and our president is speaking to most of Mexican society, which has roundly rejected the way the new U.S. administration has talked about Mexico," said Arturo Sarukhan, a former Mexican ambassador to the United States.

Bill Richardson, a former governor of New Mexico and U.S. ambassador to the United Nations, said the U.S.-Mexico relationship is at its lowest point in generations.

"The threats on paying for the wall, the threats to renegotiate NAFTA, the threats of the import fee have stoked a real nationalism in the Mexican people that is going to give President Peña Nieto very little room to maneuver," said Richardson, a Democrat.

Navigating these challenges on Peña Nieto's behalf is Videgaray, one of his closest advisers. Videgaray was Mexico's finance minister last year when Peña Nieto tasked him with outreach to the Trump campaign, where he cultivated a friendship with Kushner.

Videgaray and Kushner arranged Trump's trip to meet Peña Nieto in Mexico City last August - a visit so controversial that Videgaray was forced to resign. But even without an official post, Videgaray remained to close to Kushner, flying to New York to meet. And after Trump won, Videgaray was back in the good graces of Peña Nieto, who named him foreign minister.

"He has access to people close to Trump," said Raul Benitez Manaut, a political analyst and professor at Mexico's National Autonomous University. "Videgaray's job is to do damage control."

Videgaray visited Washington just five days after Trump's inauguration, having roughly eight hours of meetings at the White House on Jan. 25 with Kushner and Trump as well as chief of staff Reince Priebus, chief strategist Stephen Bannon, National Economic Council director Gary Cohn and National Trade Council head Peter Navarro. He has become so well-known in the West Wing that aides refer to him by his first name, Luis.

The tweet that ended the comity was perhaps as predictable as it was strident, and the fallout was swift. Kushner was angry and Videgaray cut short his trip, cancelling a scheduled meeting with John Kelly, the secretary of homeland security.

But Kushner and Videgaray kept talking. The two helped arrange a follow-up call between Trump and Peña Nieto, which officials in both countries described as tough at times, but largely cordial and constructive, including a discussion of combatting drug cartels.

"I think he's a very good man," Trump said of Peña Nieto in a recent interview with Fox News. "We have a very good relationship."

Kushner helped facilitate yet another trip for Videgaray to Washington, where on Wednesday he met privately with both Kelly and Secretary of State Rex Tillerson.

In yet another sign of Kushner's growing importance, Tillerson invited him into his meeting with Videgaray, which for the first half hour was just the three men — the U.S. secretary of state, the Mexican foreign minister and the U.S. president's son-in-law — before they were joined by additional aides.

The diplomatic community is taking note, viewing Mexico as a guinea pig. Senior officials from several other countries have already reached out to their Mexican counterparts, hoping to glean insights about the new president, the changing geopolitical dynamics in Washington, and the quiet, dimpled man behind it all — Kushner.