The 72-year-old Mr. Gauck is an outspoken former Lutheran pastor and relentless advocate of democracy and civil rights who enjoyed the backing of most major parties. He received 991 of the 1,232 ballots cast.
The ex-communist Left Party’s candidate, Beate Klarsfeld, secured 126 votes; the far-right NPD party’s candidate, Olaf Rose, only 3; and there were 108 abstentions, said Norbert Lammert, the president of Germany‘s Parliament.
Mr. Gauck opposed East Germany’s then-communist regime and became head of a federal agency overseeing the files of the Communists’ ubiquitous domestic intelligence service, the Stasi, after Germany‘s reunification in 1990.
The candidate appeared moved as he accepted the election to become the country’s new head of state, a largely ceremonial role in Germany that has little executive power but is considered an important moral authority.
“I accept this duty. After the long political meanders of the 20th century, I do so with the infinite gratefulness of a person who has finally and unexpectedly found his home again and who had the pleasure of participating in a democratic society over the past 20 years,” Mr. Gauck told the assembly.
“Very certainly I won’t be able to live up to all expectations,” he said. “But there is one thing I can promise: I say yes with all of my force and with my heart that I will carry out the responsibility you entrusted to me today.”
When Mr. Gauck was nominated, Chancellor Angela Merkel described him as “a true teacher of democracy.” Mr. Gauck had run for the opposition against her candidate, Mr. Wulff, two years earlier, but Mrs. Merkel’s junior coalition partner pushed her to accept him as president at the second attempt.
On Sunday, Mrs. Merkel said Germany can be proud of its new president, who was elected with a “very convincing result.”
“We can also be a little proud of that,” Mr. Merkel said, adding that more progress still was required to see eastern Germany catch up fully with the wealthier western part.
In 1989, Mr. Gauck, then a pastor based in the northern port city of Rostock, helped initiate protests against the communist regime in his region.
He joined a prominent opposition group in the final phase of hard-line communist rule, and after communism fell he was elected in March 1990 to serve as a lawmaker in East Germany’s first and only democratically elected Parliament until reunification that October.
Sunday’s election came exactly 22 years after that ballot, “when millions of East Germans were finally allowed to be citizens after a 56 years long reign of dictators,” Mr. Gauck said in his acceptance speech.