BERLIN (Reuters) -- Horst Koehler, the former head of the International Monetary Fund, has been elected to a second five-year term as German president by a special federal assembly in the Reichstag parliament building.

Koehler, backed by Chancellor Angela Merkel's Christian Democrats and their conservative allies in a key test of party discipline before September's parliamentary elections, won an absolute majority in the first round of voting on May 23.

Koehler won 613 votes in the 1,224-seat assembly for the office -- Germany's ceremonial head of state -- exactly the number he needed to win but one less than the CDU and their allies had in the assembly.

Gesine Schwan, a university president supported by the Social Democrats, won 503 votes. Schwan, narrowly beaten by Koehler in 2004, hoped to siphon away enough votes from the conservatives to win or at least force a second and third round.

The victory for the 66-year-old Koehler in the first round was expected to give Merkel's conservatives an important boost ahead of the September parliamentary elections, where she is seeking a second four-year term.

Merkel's CDU leads in opinion polls for September's elections but is unsure of holding the chancellery due to complex coalition arithmetic.

Half of the assembly is drawn from the 612 members of parliament and half from delegates sent by the country's 16 states.

Koehler, a former deputy Finance Minister in the CDU who in 2004 resigned as IMF managing director to run for the office that is supposed to be above partisan politics, is Germany's ninth postwar president and fourth to win reelection.

German presidents have no real political power, but past holders of the post, such as Richard von Weizsaecker, have built the office into one seen as a moral authority for the nation, stirring reflection and debate through their speeches.