Joachim Gauck said he had "listened with interest" to the Prime Minister's pledge to hold an in-out referendum on EU membership in 2017.
But he name-checked Scotland as well as England, Wales and Northern Ireland, in pleading that they remain members of the EU.
The appeal is a marked change in strategy by the Germans, who oppose any potential British exit from the EU.
Speaking on German television, President Gauck said: "Dear people of England, Scotland, Wales and Northern Ireland – dear new British citizens – we would like you to stay with us. We need your experience as the oldest parliamentary democracy, we need your traditions, your pragmatism and your courage.
"During the Second World War, your efforts helped to save our Europe – and it is also your Europe. Let us continue to engage in discussion on how to move towards the European res publica, for we will only be able to master future challenges if we work together. More Europe cannot mean a Europe without you."
The German president's appeal comes at a turbulent time for Scotland's relationship with the EU, whose president, Jose Manuel Barroso, said last year that an independent Scotland would be forced to renegotiate its membership. The SNP insists, however, that the EU would accept a separate Scotland with open arms.