Former German foreign minister Frank-Walter Steinmeier has been elected president by a parliamentary assembly.
The Social Democrat, 61, is one of Germany’s most popular politicians.
The post is largely ceremonial, but the president represents Germany abroad and is seen as carrying moral weight.
During the US election campaign, the usually circumspect ex-lawyer described Donald Trump as a “hate preacher” and predicted more challenging relations with Washington.
He has also criticised those who “make politics with fear”, and spoken out against right-wing populism.
Mr Steinmeier was chosen by the Federal Assembly meeting in parliament in Berlin.
He won 931 out of 1,260 votes.
Lawmakers and representatives from various social fields delegated by Germany’s 16 states are represented in the assembly.