BERLIN - President Horst Koehler stunned Germans by resigning yesterday after being criticized for appearing to link military deployments abroad with the country's economic interests - creating a new headache for Chancellor Angela Merkel.

The resignation, effective immediately, came a year into Koehler's second term as the largely ceremonial head of state. Merkel's center-right alliance installed the former International Monetary Fund boss as president in 2004, and his departure is a symbolic blow.

The speaker of parliament's upper house - Bremen Mayor Jens Boehrnsen, a member of the opposition Social Democrats - temporarily takes over presidential duties, largely signing legislation into law.

A new president must be elected within 30 days. German politicians now have to figure out quickly who should replace Koehler even as they are preoccupied with trying to make budget cuts amid Europe's government debt crisis.

The resignation comes on top of a much-criticized start for Merkel's second-term government, an embarrassing state election loss in May, the euro debt crisis - complete with two unpopular rescue packages - and a prominent conservative state governor's resignation.

"It is a difficult situation for Merkel," said Gero Neugebauer, a political scientist at Berlin's Free University. "It is not clear whether she will be able to push through her own candidate."

The president is chosen by a special assembly of lower-house lawmakers and representatives of Germany's 16 states, in which the center-right is expected to have a majority. Merkel gave no hints on a possible successor. The post is supposed to be above the political fray, traditionally functioning as the nation's moral voice.

Koehler, a member of Merkel's Christian Democrats, cited a week of criticism over a radio interview he gave following a visit to German troops in Afghanistan.

In that broadcast, he said for a country with Germany's dependency on exports, military deployments could be "necessary . . . in order to defend our interests, for example free-trade routes."

That was taken by many as relating to Germany's unpopular mission in Afghanistan, although his office later said he was referring to anti-piracy patrols off the coast of Somalia.

Germans are often uneasy about deployments abroad, given the country's militaristic past.