Frank-Walter Steinmeier, Germany's long-serving foreign minister who once called Donald Trump a "hate preacher", was elected as the country's 12th post-war president on Sunday by a special assembly in Berlin.
"I wholeheartedly congratulate you on the occasion of your election as President of the Federal Republic of Germany", said President Aliyev in his letter.
The president of Germany holds very little executive power.
Though the trained lawyer is usually measured in his speech, in the thick of last year's USA election campaign Mr Steinmeier labelled Donald Trump a "hate preacher".
Steinmeier is himself from the Social Democrats, the junior partner in Merkel's coalition.
Mr. Steinmeier shunned political tension or any mention of Mr. Trump in an eight-minute speech following his election, though cited Germany as an "anchor of hope" in an increasingly unsettled world.
Putin "expressed confidence that Mr. Steinmeier's work as President of Germany will promote Russia-Germany relations and efficient cooperation in various sectors in the interests of the citizens of both nations, in line with reinforcing stability and security on the European continent and globally", according to a statement from Kremlin. "Nothing will be easier, many things will become more hard". Of 1,253 votes cast, 931 were for Steinmeier.
A few years ago, Steinmeier took a several-months absence from politics, to donate one of his kidneys to his wife Elke Buedenbender.
In contrast to Gauck, Steinmeier is a career politician who served as chief of staff to former Chancellor Gerhard Schroder and later as foreign minister in Angela Merkel's first coalition government between 2005 and 2009.
The vote in the assembly may be one of the last moments of unity between Merkel's conservative Christian Democratic Union and the center-left Social Democrats as the two are expected to fiercely challenge each other in parliamentary elections in September. He returned to the Foreign Ministry when Ms. Merkel formed another so-called grand coalition with the SPD in 2013.
The United States has always been a beacon of democracy and freedom for post-war Germany, a country where the scars of World War II are never far from the surface.