President Trump walks to the podium before an event Monday in the White House. (Oliver Contreras for The Washington Post)

President Trump arrives in Japan on Thursday for a two-day gathering of global leaders with his biggest foreign policy initiatives in the balance and time running out to score a major breakthrough as he prepares to make the case for reelection.

The president is slated to meet at the Group of 20 summit in Osaka with key allies and adversaries — including China’s Xi Jinping, Russia’s Vladimir Putin, Japan’s Shinzo Abe, Saudi Arabia’s Mohammed bin Salman and India’s Narendra Modi — as he seeks to clinch an elusive trade pact with Beijing, consolidate international support in a tense staredown with Tehran and navigate a path forward on stalled nuclear talks with North Korea.

The complex panoply of issues has threatened to destabilize the global economy and potentially plunge the United States into another military conflagration in the Middle East. Though Trump has projected confidence, his tactics have set foreign capitals on edge, with fellow leaders uncertain in which direction the mercurial and impulsive president intends to head next.

The upshot is that 2½  years into his presidency, Trump is facing a crucial test of his “America First” agenda, one that has alienated traditional allies over disputes on trade and defense spending and set the United States apart from global consensus on how to deal with climate change and Iran’s nuclear program.

Having generally thumbed his nose at multilateral engagements in favor of a go-it-alone approach, Trump has shown a preference for leader-to-leader diplomacy and following his gut instincts instead of rigorous preparation, which have left him in a precarious position.

Xi held a hard line on trade talks despite an escalating tariff war. North Korean leader Kim Jong Un refused Trump’s demands to relinquish his full nuclear arsenal in exchange for sanctions relief. And Iran’s Ayatollah Ali Khamenei flatly rejected Trump’s offer to negotiate, after the United States pulled out of the Iran nuclear deal.

“We’re entering the third phase of the Trump administration’s foreign policy,” said Thomas Wright, an analyst at the Brookings Institution. He pointed to the early days of the administration — during which Trump was surrounded by more seasoned, establishment figures in his Cabinet — as a period of relative constraint, followed in the past year by a more emboldened Trump who sought to shape global affairs more aggressively.

“Now comes the reckoning — in which he is facing up to the consequences of his own choices and the contradictions within them,” Wright said. “I think he had a bit of leeway because America has been as strong as it is, but on Iran and China and Venezuela and a variety of other issues, he’s facing tougher choices.”

In recent weeks, Trump has professed confidence, and a measure of patience, suggesting that he is content to outlast his negotiating rivals on the strength of his bargaining position, including an economy that is outperforming much of the globe. Tariffs and sanctions are biting, White House aides said, and the president believes he is increasing his leverage.

Aides dismissed the notion that the president is feeling pressure to quickly resolve some of his major foreign policy initiatives or that he is reeling under the weight of so many competing demands for his attention.

On China, Trump said during a speech at his campaign kickoff rally in Orlando last week that he was aiming for “a good deal and a fair deal” with China, but even if a deal falls through “that’s okay, too.” On North Korea, he has continued to communicate with Kim through personal letters, but aides emphasized that the president has maintained punishing economic sanctions.

“I don’t think the president is feeling any pressure on either of those accounts,” said a senior administration official who spoke on the condition of anonymity to preview the G-20 during a conference call with reporters. “In terms of trade talks, I’ve heard the president say on any number of occasions he’s comfortable where we are and comfortable with any outcomes of those talks.”

Aides said Trump also is scheduled to meet with Australian Prime Minister Scott Morrison, German Chancellor Angela Merkel and Turkish President ­Recep Tayyip Erdogan. On Tuesday, a Turkish court released a U.S. Consulate employee from house arrest for health reasons, Reuters reported. Nazmi Mete Canturk, a Turkish security officer, and his wife and daughter are accused of links to Fethullah Gulen, the U.S.-based Muslim cleric blamed by Turkey for a 2016 coup attempt.

After two days in Osaka, Trump will visit Seoul for bilateral meetings with President Moon Jae-in, including a potential trip to the Korean demilitarized zone.

The president is keenly aware of how his international gambits are playing on the campaign trail. He has kept a close eye on the Democratic primary field, sensitive to the prospects that an imperfect deal with Beijing or Pyongyang could unravel next year and expose him to criticism during the heart of the campaign. Trump said he authorized a missile strike on Iranian targets after that nation shot down a U.S. drone, only to call it off due to his concern that there would be too many casualties, perhaps mindful that a deepening conflict could sink the United States into the kind of extended overseas military engagement he campaigned against.

While abroad, the president will be competing for attention with the first rounds of the Democratic primary debates on Wednesday and Thursday nightsin Miami.

Trump professed a win in his confrontation with Mexico over efforts to curb illegal immigration at the southern border of the United States. After he threatened to hike tariffs, the Mexican government agreed to deploy thousands of national guard troops to stop Central American migrants from entering the United States — although it remains uncertain whether the effort will significantly reduce the number of asylum seekers, which is at a 12-year high.

In other arenas, however, the administration has made losing bets. The White House vocally backed opposition leader Juan Guaidó’s aborted attempt to oust strongman Nicolás Maduro in Venezuela. A two-year effort from the White House, led by senior adviser Jared Kushner, to broker a Middle East peace plan has fallen flat, with both Palestinian and Israeli government representatives expected to boycott a regional economic investment conference this week in Bahrain.

Meanwhile, many of Trump’s trade initiatives have stalled. He is waiting for Democrats to decide whether to approve a new trade deal with Mexico and Canada. He has held off on threats of auto tariffs on the European Union and Japan but has begun to crack down on imports from India, demonstrating that Trump’s protectionist platform is still expanding.

David Dollar, a former top Treasury Department official in Beijing during the Obama administration, likened Trump’s current posture as that of a juggler and said “it’s hard to keep six balls in the air.”

All the uncertainty on the White House’s trade approach could be freezing business investment and hurting the economy, Dollar said, emphasizing that it will take months before it can be determined whether the strategy pays any dividends.

“Either this was a failed strategy or this was a brilliant strategy,” he said.

Further complicating matters is the view in foreign capitals that Trump’s days could be numbered as the 2020 election approaches and the calculation that it makes little sense to take risks on a deal with a president who might not be around in two years — and who has failed to deliver on many of his major objectives.

“Guys like Xi and Putin and Erdogan are not used to not getting things their way,” said Kevin Nealer, a risk analyst at the Scowcroft Group. “They may be coming up with a coping strategy for Trump to play small ball and not take risks to accommodate Trump because he may be a short-timer.”

They may also be questioning whether Trump can deliver on what he promises.

“Autocrats smell weakness in other autocrats and in Trump — whether it’s the head-fake on Iran, or Venezuela where he didn’t deliver, or the Israeli peace plan — they hold him to his own description of his agenda and say, ‘There’s not a lot there,’ ” Nealer said. “Add into it their individual relations with him — whether it’s increasing China tariffs and the equivocal messages that Putin and Erdogan are getting — and their main takeaway is the unreliability of Trump and the United States.”