German President Horst Koehler says he is resigning immediately, following criticism of remarks he made about German military deployments abroad.
Mr Koehler, whose job is largely ceremonial, had linked missions such as the Afghanistan deployment with the defence of economic interests.
His remarks drew criticism from a number of German politicians.
Mr Koehler, 67, was re-elected last year to serve a second five-year term as president.
He made the controversial remarks in a radio interview after a brief visit to Afghanistan earlier this month.
He said that for an export-orientated country like Germany, it was sometimes necessary to deploy troops "to protect our interests... for example free trade routes".
Announcing his resignation on Monday, he said "it was an honour for me to serve Germany as president".
With his wife standing next to him, he said he regretted that his comments could lead to a misunderstanding about a difficult question for the nation.
Jens Boehrnsen, speaker of the parliament's upper house (Bundesrat), will be interim president. He is in the opposition Social Democratic Party (SPD).
The BBC's Oana Lungescu in Berlin says Mr Koehler's remarks about military missions led to accusations of gunboat diplomacy and embarrassment for Chancellor Angela Merkel's government. It has come under strong popular pressure to withdraw troops from Afghanistan.
Mr Koehler's shock decision could hardly have come at a worse time, our correspondent says. Polls show that the government's approval rating has plummeted to a four-year low, mainly due to its management of the eurozone crisis.