German Chancellor Angela Merkel has congratulated Donald Trump on his win in the US presidential election, before underlining the importance of their countries' relationship and reminding the president-elect of their shared values.

"Whoever the American people elect as their president in free and fair elections, that has a significance far beyond the USA," the chancellor said in Berlin on Wednesday.

"Germany and America are bound by their values: democracy, freedom, the respect for the law and the dignity of human beings, independent of their origin, skin color, religion, gender, sexual orientation or political position," she added. "On the basis of these values I offer the future president of the United States, Donald Trump, close cooperation."

The initial cooperation between the two countries is likely to be tense. At one point in his election campaign, Trump described Merkel's immigration policy as "a total disaster," and the immediate reaction to his victory across Germany's political spectrum was shock and uncertainty.

Defense Minister Ursula von der Leyen put a brave face on as she became the first senior member of Merkel's government to offer her comments. Trump's win, she said, was a "heavy shock."

Trump caused an upset in the US election

"Of course, we Europeans know as NATO partners that Donald Trump will ask himself what we are contributing to the alliance," the conservative member of Merkel's Christian Democratic Union (CDU) told TV network ARD. "But we will also be asking, what is your position on the alliance? Many questions are open. A responsible and open America is in our interests.

"I also think that Donald Trump knows that this wasn't an election for him, but against Washington, against the establishment," von der Leyen added.

There was similar concern from Foreign Minister Frank-Walter Steinmeier. "Nothing will be easier, a lot will be more difficult. We don't know how Donald Trump will govern America," he told the DPA news agency on Wednesday. "But we have to accept the result and we will accept it."

As if in response to German anxieties, US diplomats offered reassurance.

"There is no question that Germany is still our indispensable partner," the US Ambassador to Germany John Emerson told DW.

Member of the CDU's coalition partners, the Social Democratic Party (SPD), were similarly uncertain about what the result meant. "The world won't end, it just keeps getting crazier," tweeted SPD Justice Minister Heiko Maas:

Maas' party leader, Vice Chancellor Sigmar Gabriel, called Trump's victory a "rollback to the old, bad times."

'Not particularly well-educated'

Opposition politicians described the Republican victory in even more drastic terms. As the results began tipping in Trump's favor, Green party leader Cem Özdemir called the possibility of his presidency a "break with the tradition that the West stands for liberal values," and he warned that the United States could turn its back on the rest of the world.

Meanwhile Left party chairman Bernd Riexinger struck a fatalistic tone: "He won't be able to offer anything at all to the people who he's promised all kinds of things." The Left party's popular former leader Gregor Gysi was typically candid when he offered his opinion of the president-elect to Deutschlandfunk radio: "He's a simple soul, not particularly well-educated, he's coarse," he said. "We've never had anything like this in this form as president of the United States, even though there have been what I would consider bad presidents before. I think this will give right-wing populism a new boost in Europe."

As if to confirm Gysi's fears, it soon emerged that the only major German party to welcome Trump's victory outright was the populist Alternative for Germany (AfD). Deputy party leader Beatrix von Storch was quick to draw parallels with the European political situation. "The victory of Donald Trump is a signal that the citizens of the Western world want a clear political change," she wrote on her Facebook page.

Her party colleague Marcus Pretzell took to Twitter to ask for more "optimism" and less "fearmongering" from the German media - and reached for a quote from Romantic-era German poet Johann Wolfgang von Goethe to sum up the moment: "From here and today a new epoch of world history will begin, and you can say you were there."