It is unprecedented for a German chancellor to lecture a US president-elect on democratic values — but Angela Merkel has been so shaken by Donald Trump’s victory that she did exactly that in her letter of congratulation to the man heading for the White House.

“Germany and America are bound by common values,” she wrote. “Democracy, freedom, as well as respect for the rule of law and the dignity of each and every person regardless of their origin, skin colour, creed, gender, sexual orientation or political views.” Future co-operation, the EU’s most powerful leader added, would be “based on these values”.

For Germany to set such conditions for working with the US is unheard of. But so is the nature of the gauntlet that Mr Trump has thrown down, after a campaign in which he not only caused outrage with his views on themes covered in Ms Merkel’s letter but also insulted the German chancellor, calling her policies “a catastrophe”.

At issue now is whether Mr Trump turns some of his campaign slogans directly into policy — or adopts more moderate lines. Among the big questions for the EU are what will happen with Mr Trump’s threats to reduce US commitment to Nato, come to an accommodation with Russia and unwind free-trade agreements.

Ms Merkel clearly felt she had to send an early signal to Mr Trump that if he would not defend the liberal-democratic values underpinning the transatlantic alliance, she would, analysts say.

Daniela Schwarzer, head of the Berlin-based DGAP foreign policy think-tank, says: “The point is that it is not only US policy that might be changing, but the US’s role as the west’s shining focus. It now might stop shining.”

Germany and America are bound by common values. Democracy, freedom, as well as respect for the rule of law and the dignity of each and every person regardless of their origin, skin colour, creed, gender, sexual orientation or political views

The pro-American Ms Merkel may have been driven partly by her well-known love of democratic freedoms — a legacy of her upbringing in the ex-communist East Germany, as biographers have noted.

She may also have wished to reassure both American voters who backed Hillary Clinton and many Europeans. The German chancellor fears that populist forces, which have come to power in Poland and driven the UK towards Brexit, could gain more ground, notably in France, where Marine Le Pen is campaigning for the presidency in next year’s election, and even in Germany, which holds parliamentary polls in 2017.

The anti-immigration rightwing Alternative for Germany, which scores around 12 per cent in opinion polls, has been inspired by Mr Trump’s victory. “Demagogic populism is not only a problem in America,” Wolfgang Schäuble, Ms Merkel’s finance minister, said on Thursday.

Ms Merkel, who heads the conservative CDU/CSU bloc in Germany’s ruling coalition, spoke out knowing that her Social Democrat partners are even more hostile to Mr Trump. Sigmar Gabriel, the SPD leader and deputy chancellor, said: “Trump is the trailblazer of a new authoritarian and chauvinist international movement.”

Public opinion in Germany is against the Republican. A post-election ZDF television survey showed 86 per cent of Germans say Mr Trump’s election is bad. The media bemoan his success. In Bild, the daily newspaper, a columnist said: “I cannot imagine how Angela Merkel will speak with Donald Trump …She knows what he thinks of women. She knows he grabs women in the crotch.”

Meanwhile, German politicians assume that even if Mr Trump moderates his promises to reduce US spending on global security and cut Nato commitments, Germany and the EU will have to bear a bigger burden.

“Europe needs a common political will for greater relevance in security policy,” defence minister Ursula von der Leyen wrote in the Rheinische Post newspaper, calling for more defence co-operation and spending.

Ms Merkel has long been ready to take the lead in international crises, notably over Ukraine, where she has successfully championed western sanctions against Moscow, and in the refugee question, where she is pushing other EU states to look beyond their borders and work with fragile countries in the Middle East and Africa.

Ms Schwarzer says Berlin will continue to shoulder its responsibilities. But she notes that German leadership, as over Ukraine, has rested on a firm Transatlantic alliance. “If this breaks,” she says, “Germany would not retreat but it would have to be less ambitious.”