Gauck succeeds Christian Wulff, a conservative who had survived only 20 months of the five-year term before stepping down amid accusations of corruption dating from his time as a state premier.
Wulff himself had stepped in to replace Horst Koehler, who quit under a cloud after he seemingly justified using the military to advance Germany's economic interests.
Gauck's election is also a yardstick of how far East Germans have come since they joined the Federal Republic (West Germany) in the unification of October 1990.
In a wonderful coincidence, his election came on the 22nd anniversary of the first - and only - free elections in East Germany. Within seven months, the German Democratic Republic was no more - it had been unified with the West.
"I accept this task with the infinite thanks of a man who finally, unexpectedly, found a home after trekking through the political deserts of the 20th century," Gauck said.
Gauck has had no big role in public life for a decade. He expressed astonishment at his nomination and cautioned against those who have excessive hopes in him. "I will be unable to fulfil everyone's expectations, that is certain."
His reputation is rooted in the grimmest, darkest times of Germany's post-war history.
At a time when between one in three and one in four of the East German public were informers for the Stasi, the communists' secret police, Gauck was among the very few who did not curry favour with the regime.
When Gauck was 11, his father was sentenced by a Soviet military tribunal to 25 years in a Siberian gulag for anti-Soviet agitation after he received a letter from the West. He returned home four years later a broken and bitter man.
Gauck hoped to study German at university in order to become a journalist. When this path was closed to him because he refused to join the Communist Party, he studied theology instead, entering the Lutheran Church, where he was ordained in 1967.
As the Catholic Church nurtured the opposition in Poland, the Protestant Church became the cradle of the opposition in East Germany.
Gauck used his pulpit to attack oppression but only belatedly took part in the protests against the regime that began in mid-1989. He became a figurehead of a protest movement in Rostock, a rundown port on the Baltic coast, helping to form a pro-democracy coalition which tightened the noose around the ruling communist party as it fought to stay in power.
After the communists fell, Gauck took charge of a commission that collected and oversaw the millions of files of the Stasi - the East German equivalent of South Africa's post-apartheid Truth and Reconciliation Committee.
Within Europe, Gauck's reputation for moral strength lies in the same league as Vaclav Havel and Lech Walesa, but he is also criticised in some quarters in Germany for being outspoken on moral issues but knowing little about the world.