German President Horst Koehler has been re-elected for a second five-year term.
Correspondents say Mr Koehler's re-election is a symbolic victory for Chancellor Angela Merkel ahead of national elections in September.
Federal and state parliamentarians re-elected Mr Koehler over a strong challenge from Gesine Schwan of the centre-left Social Democrats.
The post of president is largely ceremonial but carries considerable moral authority.
Mr Koehler, 66, is a former head of the International Monetary Fund and a member of the chancellor's Christian Democratic Union.
Parliament President Norbert Lammert said Mr Koehler won 613 votes from the special parliamentary assembly in the Bundestag to achieve a slim majority.
The 1,224-member assembly comprises lower-house politicians and delegates nominated by Germany's 16 state legislatures.
The closest challenger was Gesine Schwan of the centre-left Social Democrats, who won 503 votes.