President Biden has been a coalition-builder on the world stage. But as he seeks re-election, he is facing the re-emergence of the far right—and the specter of the strongman—both at home and abroad.

Biden’s ability to hold together a Western alliance, central to the defense of Ukraine in its war against Russia, will be at the forefront when he arrives Wednesday in southern Italy’s Puglia region for the Group of Seven industrialized nations summit.

The meetings fall at a perilous time for Biden’s campaign and his efforts to promote democracy and alliances abroad. Former President Donald Trump ’s inward-looking model , emphasizing high barriers to trade and immigration and a transactional approach to international relations, is serving as a challenge to Biden’s approach at home and in Europe, where some far-right parties made gains during this week’s European Union elections.

“It has a feeling, to me, of last chance to do something big before things may change significantly,” said Josh Lipsky, senior director with the GeoEconomics Center at the Atlantic Council, a Washington-based think tank.

The G-7 nations—the U.S., Canada, France, Germany, Italy, Japan and the U.K.—have formed a bulwark of support for Ukraine in its battle against Russia, providing Kyiv with billions of dollars in military and humanitarian aid. Future assistance hinges on G-7 nations remaining united in that cause, however, and recent elections, along with Biden’s November contest against Trump, could put that support to the test. The leaders of all seven nations, Biden included, are posting low approval ratings .

In much of Europe, sluggish growth, the cost of living, immigration and the war in Ukraine are fueling political anxiety and frustration with political incumbents.

French President Emmanuel Macron called snap national elections Sunday after his centrist party was trounced by the far-right opposition National Rally in elections for the European Parliament.

German Chancellor Olaf Scholz fared little better in the European elections: His governing Social Democrats won just 14% of the vote, the party’s worst result in a nationwide ballot since the Reichstag elections of 1887.

British Prime Minister Rishi Sunak ’s fractious Conservative Party is trailing the center-left opposition by about 20 percentage points ahead of a July 4 national election. And in Canada, Prime Minister Justin Trudeau ’s weak poll numbers are giving Conservatives an opening in the next national election.

Italian Prime Minister Giorgia Meloni , who is hosting the G-7 summit, is an exception: Her right-wing alliance performed well in the European elections. Meloni comes from a far-right populist background, and is still adept at channeling many voters’ discontent with Europe’s political establishment, even as she becomes one of its leading power brokers.

Biden is scheduled to meet Thursday with Ukrainian President Volodymyr Zelensky along the sidelines of the G-7 and then hold a joint news conference, said John Kirby, a spokesman for the National Security Council. Kirby said the administration remained confident “regardless of who gets what seat in the EU parliament” that the U.S. would be able to work closely with European allies and continue to support Ukraine.

The prospects of Trump’s return to the world stage will loom over the event, which will take place two weeks before Biden and Trump meet in the first general-election debate of the 2024 presidential race. Polls have shown Biden and Trump, the presumptive Republican nominee, engaged in a tight contest that will be decided by the outcome in roughly six battleground states.

Trump has claimed that the war in Ukraine would never have happened on his watch and asserted that he could persuade Russian President Vladimir Putin to negotiate an end to the conflict. He has questioned why the U.S. has been sending billions of dollars in aid to Ukraine with mounting problems at home. But in recent months, he quietly accepted the passage of a short-term security supplemental aid to Ukraine and endorsed proposals by some Republicans to support Ukraine in the form of a loan that would be repaid.

Trump has embraced far-right leaders around the world, including in Europe—many of whom echo his strict border policies and tough rhetoric about immigrants. He has praised Marine Le Pen , the leader of France’s National Rally, and formed a close friendship with Hungarian Prime Minister Viktor Orban , who has pushed back on European support for Ukraine and created obstacles for the newest members of the North Atlantic Treaty Organization—Sweden and Finland—to join.

Biden has sought to draw a contrast with his Republican rival. He traveled to France last week to commemorate the 80th anniversary of the Normandy landings, events he used to make the case for democratic principles and sustained Western commitment to Ukraine. “We will not walk away because if we do, Ukraine will be subjugated,” Biden said in Normandy. “And it will not end there. Ukraine’s neighbors will be threatened. All of Europe will be threatened.”

Biden is expected to deliver that message at the G-7 and again next month when he convenes the annual NATO summit in Washington to mark the 75th anniversary of the security and political alliance.

Trump has long sparked concern over the future of the NATO alliance with threats that the U.S. won’t respect the military bloc’s collective-defense pact if a member country that hasn’t met the alliance’s military-spending quota comes under attack. Nations who are members of the alliance pledge to spend 2% of their gross domestic product on defense.

Trump’s appearances at G-7 summits during his tenure rattled Western allies. In 2017, he refused to sign onto a statement with allies supporting the Paris climate accord and then withdrew from the agreement . (The U.S. rejoined the climate pact on Biden’s first day in office.) And in 2018, Trump refused to sign a joint G-7 statement along with allies and called Canada’s Trudeau “very dishonest and weak” after departing the summit.

Biden, for his part, frequently points to the current moment as a crucial one for democracies to show they can deliver for their citizens. In fundraisers, he has recalled attending his first G-7 as president and telling Macron in the meeting that “America is back. [Macron] looked at me and said, ‘For how long, Joe?’ ”

Ukraine will figure prominently in the discussions in Italy. G-7 leaders hope to reach agreement on a financing plan that would provide Ukraine with as much as $50 billion in aid based on the investment returns generated by roughly $300 billion in frozen Russian assets. The sovereign assets were frozen by the U.S. and Europe after Russia’s invasion of Ukraine, and the Biden administration is hoping to create a financial instrument to deliver years worth of expected profits on Russian assets, mostly interest payments, to Kyiv in the short term.

Kirby said the U.S. also would “announce an impactful set of new sanctions and export control actions” against Russia during the trip. The G-7 leaders also will be joined by Pope Francis for a session on artificial intelligence.

Besides coordinating aid to Ukraine, the U.S. must persuade European allies to confront China for its support of Moscow with exports that have enabled Russia to rebuild its military in the face of unprecedented Western sanctions.

Biden is also facing cracks with Europe over his staunch support for Israel as it pursues its offensive against Hamas in Gaza. Some European nations have said they would recognize an independent Palestinian state, reflecting their deepening frustration with Israel and the rising civilian casualties.

Write to Ken Thomas at ken.thomas@wsj.com and Marcus Walker at Marcus.Walker@wsj.com