BERLIN — President Obama urged his successor to continue his policy on Russia on Thursday, saying President-elect Donald Trump should not fall into the trap of seeking short-term deals with the rival power for the sake of expediency.

He said Trump should take a constructive approach, "finding areas where we can cooperate with Russia where our values and interests align," but "willing to stand up to Russia when they are deviating from our values and international norms."

"My hope is that he does not simply take a realpolitik approach" in cutting deals and doing "whatever's convenient at the time," Obama said.

The president's comments on Russia were his most extensive since Trump's election in a campaign often influenced by reports of Russian involvement in the hacking of emails from his opponent's campaign and by Trump's own public entreaties to Russian President Vladimir Putin.

They came as Obama stood by his most important European ally, Chancellor Angela Merkel, for what will likely be their last meeting of his presidency. For her part, Merkel said she was impressed with how smoothly the presidential transition was going. "This is to us a sign of encouragement to continue the cooperation we have built," she said. "I approach this with an open mind."

Their meeting covered hot-button issues like Ukraine, the Islamic State and Syria, but also broader issues of climate change, migration and trade. They shared an optimistic vision for a new kind of globalization, tacitly rejecting the more isolationist philosophy that drove Trump's campaign.

"It is my conviction that globalization — and I think we share this conviction — globalization needs to be shaped politically, it has to be given a human face, but we cannot fall back to pre-globalization times," Merkel said at a joint press conference after meeting with Obama in Berlin.

Obama and Merkel laid out their global vision in a joint op-ed in the German magazine Wirtschaftswoche, as they prepared for what may be their final meeting of Obama's presidency. Obama described Merkel this week as "probably been my closest international partner these past eight years," and their joint statement argued that the partnership should endure beyond his tenure.

"Germany and the United States are deeply linked together," the two leaders wrote. "Today we find ourselves at a crossroads — the future is upon us, and we will never return to a pre-globalization economy. Germans and Americans we must seize the opportunity to shape globalization based on our values and our ideas. We owe it to our industries and our peoples — indeed, to the global community — to broaden and deepen our cooperation."

The German leg of Obama's last foreign trip as president echoes his remarks in Greece Wednesday, when he defended globalization as a force for prosperity and democratization, but urged a "course correction" to ensure that workers and their families benefit from the wealth created.

On Friday, Obama and Merkel will have more meetings with the leaders of the United Kingdom, France, Italy and Spain, as Western leaders try to adapt to a world order shaken up by Trump's election and the U.K.'s vote to leave the European Union.

In their op-ed, Obama and Merkel also emphasized the importance of the NATO alliance, as European leaders continued to worry about the impact of a Trump presidency on their collective security. And they touted U.S.-German cooperation in addressing a host of global problems, including the coalition against the Islamic State, the refugee crisis and the Paris climate agreement.

And on trade, Obama and Merkel called German-American economic relations "an unshakeable core" of global trade. "Simply put: we are stronger when we work together," they said,

Obama's trip to Germany is the sixth of his presidency, tying France as his most-visited foreign destination. Obama and Merkel were clearly feeling nostalgic about the meeting, but Obama said he would be back. "I have somehow continued to miss Oktoberfest. That is something that is probably better for me to do as a former president than as a president. I'll have more fun," he said.

Though the trip was planned before the election, Obama said his mission is now to reassure Europe that the U.S. commitment to common defense is steadfast. Before departing Washington, Obama said Trump had "expressed a great interest in maintaining our core strategic relationships."

Still, there's a palpable sense of uncertainty among allies about the future of the Western alliance. During the campaign, Trump said he would consider whether a NATO ally had spent enough on its own military before deciding whether to commit the United States to defend it.

"This is no time to question the value of the partnership between Europe and the United States," NATO Secretary General Jens Stoltenberg wrote in an op-ed in the Guardian Tuesday, not mentioning Trump by name. "Going it alone is not an option, either for Europe or for the United States."