Former German foreign minister Frank-Walter Steinmeier has been elected president by a parliamentary assembly.
The Social Democrat, 61, is popular, scoring highly in opinion polls.
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 former lawyer described Donald Trump as a “hate preacher” and predicted more challenging relations with Washington.
Mr Steinmeier was chosen by the Federal Assembly meeting in parliament in Berlin.
The assembly groups 1,260 lawmakers and representatives from various social fields delegated by Germany’s 16 states.
Electors included Olivia Jones, a colourful drag queen sent to vote by the Green Party in Lower Saxony.
Mr Steinmeier, who takes up the post on 19 March, held the post of foreign minister twice for a total of eight years.
Both terms were served under Chancellor Angela Merkel in grand coalitions of Christian Democrats and Social Democrats.
In 2009, he stood unsuccessfully against Mrs Merkel in the federal election.
Mr Steinmeier’s election to the presidency is seen as a boost by the Social Democrats as they seek to unseat Mrs Merkel in September’s federal elections.
The current post-holder, President Joachim Gauck, decided against bidding for a second five-year term due to his age – 77.
Mr Gauck is a former Lutheran pastor and civil rights activist in the former East Germany.
Mrs Merkel’s Christian Democrats failed to find their own candidate for the presidency.
Other candidates included Christoph Butterwegge from the opposition Left Party, and Albrecht Glaser from the anti-immigrant Alternative for Germany.
Germany president: Steinmeier chosen by lawmakers have 293 words, post on www.bbc.com at 2017-02-12 13:25:58. This is cached page on WBNews. If you want remove this page, please contact us.