BERLIN (AP) — U.S. President Joe Biden said it’s important for Ukraine’s Western allies to “sustain our resolve” in supporting the country as he met Friday with European partners, with the upcoming U.S. presidential election casting a long shadow over his visit to Germany.

Biden met Chancellor Olaf Scholz of Germany, Ukraine’s second-biggest military supplier after the U.S. They were joined by French President Emmanuel Macron and British Prime Minister Keir Starmer for discussions that also addressed the conflict in the Middle East.

With the election just weeks away and the race extremely tight, there are worries that a victory for Donald Trump, the Republican nominee, could upset the relationships that Biden is hoping to pass on to Vice President Kamala Harris, the Democratic nominee.

Trump has an appetite for imposing trade tariffs on key U.S. security partners. He has expressed indifference to the security of Ukraine, refusing to say during a presidential debate if he wants the U.S. ally to win its war against Russia. He’s voiced doubts about coming to the defense of NATO members if they come under attack.

The gathered leaders never uttered Trump’s name in public, yet their remarks often hinted at the possibility that he could withdraw support from Ukraine and scorn global alliances that Biden and his counterparts view as critical.

Biden in an exchange with reporters following his meeting with the three European leaders suggested that the U.S. election was discussed in the private talks. Asked if the leaders were worried about the presidential race, Biden responded tersely, “They’re interested.”

Earlier in the day Biden emphasized the need to support Ukraine.

“As Ukraine faces a tough winter, we must — we must — sustain our resolve, our effort and our support,” Biden said.

Scholz said that “we will stand beside Ukraine as long as it is necessary,” pointing to a planned $50 billion international loan package funded by interest on profits from frozen Russian assets.

“Our position is clear: We are supporting Ukraine as strongly as possible,” he added. “At the same time, we are taking care that NATO does not become a party to the war so that this war doesn’t culminate in an even bigger catastrophe.”

Scholz has indicated that he’s skeptical about aspects of a “victory plan” drawn up by Ukrainian President Volodymyr Zelenskyy, and says he will stand by his refusal to supply Taurus long-range cruise missiles to Kyiv.

Biden is also opposed to loosening restrictions on letting Ukraine use western weapons to strike deeper into Russia, but did not shut the door on the issue.

“In foreign policy, there’s never a ‘never will I change my mind,’” Biden said. “Right now there is no consensus on long-range weapons.”

Biden didn’t want his term to end without visiting Berlin, after having been to other key allies such as Japan, South Korea, France, India, the U.K., Poland and Ukraine. The visit was a quick one, with Biden spending about 20 hours on the ground in Berlin.

Concerns about what might come next were reflected as Biden received the highest class of Germany’s Order of Merit, which was also bestowed on former U.S. President George H.W. Bush in recognition of his support for German reunification.

German President Frank-Walter Steinmeier said the friendship with the U.S. is “and will always be existentially important” for Germany, but there have always been “times of proximity and greater distance.”

“Even recently, just a handful of years ago, the distance had grown so wide that we almost lost each other,” Steinmeier said, in an reference to tense relations during Trump’s earlier presidency. He said Biden “restored Europe’s hope in the trans-Atlantic alliance literally overnight.”

Recalling the “wide sweep of history” he has seen in his 81 years, Biden said, “we should never underestimate the power of democracy, never underestimate the value of alliances.”

As he met Scholz, Biden said he was “grateful for Germany’s cooperation in holding Iran accountable for destabilizing policies, including providing missiles and drones to Russia to use against Ukraine.” He pointed to new European sanctions against Iran’s leading airlines and said that “this coordination is going to have to continue.”

Biden reiterated his call for Israel to pursue peace after the killing of Hamas leader Yahya Sinwar — which he described as “a moment of justice.”

“I told the prime minister of Israel yesterday, let’s also make this moment an opportunity to seek a path to peace, a better future in Gaza without Hamas,” he said.

Biden said he and the European leaders discussed the way ahead following the killing of Sinwar. He suggested that negotiating a cease-fire deal between Israel and Hezbollah could be easier than forging one between Israel and Hamas.

“We think that there is a possibility of working for a ceasefire in Lebanon and it’s going to be harder in Gaza,” Biden said. “But we agree there has to be an outcome of what happens the day after.”

Biden declined to say whether Israeli Prime Minister Benjamin Netanyahu gave him assurance in their Thursday phone call that the Israelis are ready to get back to negotiations on the stalled cease-fire deals.

“We’re in the middle of discussions about that,” Biden said. “I’m not going to get into that.”

Trump has said his approach will help the U.S. economy and prevent foreign countries from taking advantage of the United States. He maintains that if he were still president, Russia would never have invaded Ukraine in 2022 and Hamas would never have attacked Israel in 2023.

“I will end the war in Ukraine, stop the chaos in the Middle East, and prevent World War III,” he said at a recent rally in Georgia.

Harris, for her part, has voiced strong backing for Ukraine and tracks with Biden on support for Israel, while placing particular emphasis on the need to relieve the suffering of Palestinian civilians whose lives have been upended by the Hamas-Israel war.

AP writer Aamer Madhani in Washington contributed reporting.