BERLIN (Reuters) - U.S. President Barack Obama gave a strong endorsement of German Chancellor Angela Merkel on Thursday and used a visit to Berlin to warn Russia about consequences for intervening in the U.S. election and prod Donald Trump to hold firm against Moscow.

U.S. President Barack Obama and Chancellor Angela Merkel smile during their press conference at the German Chancellery in Berlin, Germany November 17, 2016. REUTERS/Kevin Lamarque

On a sentimental final trip to Germany as president, Obama expressed hope that the New York businessman who has never previously held public office would jettison controversial campaign rhetoric when he entered the White House and keep democratic values in mind as he chose his staff.

“What makes me cautiously optimistic about my successor and the shift from campaign mode to governance is there is something about the solemn responsibilities of that office ... that it forces you to focus,” Obama said.

“If you are not serious about the job, then you probably won’t be there very long because it will expose problems.”

Republican Trump defeated former Secretary of State Hillary Clinton, a Democrat, in an upset election after criticizing his opponents in sharply-worded blasts on Twitter, promising to build a wall on the U.S. border with Mexico, and pledging to ban Muslims temporarily from entering the United States.

He also praised Russian President Vladimir Putin, whose annexation of Crimea from Ukraine led to western sanctions.

Obama, who along with Merkel called for those sanctions to be renewed until Russia complied with international agreements, said he hoped Trump would be pragmatic in dealing with Washington’s former Cold War foe.

Slideshow ( 9 images )

“My hope is that he does not simply take a realpolitik approach and suggest that we just cut some deals with Russia even if it hurts people, even if it violates international norms or even if it leaves smaller countries vulnerable or creates long term problems in countries like Syria,” Obama said.

Obama said he had spoken to Putin before the U.S. election about cyber attacks that U.S. officials said were an attempt to influence the presidential race and told him Washington would respond appropriately. Moscow has dismissed the allegation.

HARD TO SAY GOODBYE

Merkel, a Russian speaker who grew up in the former East Germany, has helped lead European efforts to sanction Russia.

She and Obama forged a particularly close relationship, and his stop in Berlin on his farewell tour reflected that.

“The parting is hard for me,” Merkel acknowledged, adding she had to accept that the U.S. constitution limited a president’s time in office to eight years, drawing a wink and a smile from Obama.

No such limits exist in Germany, and Merkel has declined to say whether she will run in a general election next year in which her conservatives are expected to remain the largest bloc in parliament.

Obama indicated he hoped she would. “Chancellor Merkel has been an outstanding partner,” he said.

Many in Germany expect Merkel to run, adding to what would be 12 years in power. The chancellor said on Thursday it was not the time to announce such a decision.

“If she chooses to continue, she will have big burdens. I wish I could be there to lighten her load,” he said, declaring Merkel “tough.”

The two leaders dined together at Obama’s hotel on Wednesday and did the same at the chancellery on Thursday night. On Friday, they will meet with other European leaders before Obama heads to Peru the final stop on his trip.