Lawmakers were widely expected to vote for Merz in what was considered a formality.
Conservative leader Friedrich Merz initially failed on Tuesday to gain enough votes to be elected chancellor by the German Parliament.
Hours later, however, in a dramatic second round, Merz rallied to secure 325 votes and formally claim the chancellorship.
What was supposed to be a shoo-in turned into a shock defeat for Merz, who became the first candidate since the establishment of the parliament at the end of World War II to fail to garner the majority support needed.
In Februaryโs general election, Merzโs center-right CDU won the highest number of votes at 22.5 percent, falling short of a majority. After lengthy negotiations, the CDU made an agreement with the center-left SPD to form a coalition government.
Lawmakers were widely expected to back Merz as chancellor in what was considered a formality in a vote in the lower house of parliament.
Merz won just 310 votes in the first round of voting, Bundestag President Julia Kloeckner said. He needed 316 to secure a majority.
However, just hours after his defeat, the vote was re-run and he was elected chancellor.
Merz has vowed never to govern with the right-wing party Alternative for Germany (AfD), which came in second in the general election, even though doing so would ensure a clear majority.
AfD leader Alice Weidel told The Epoch Times that the result was โa sign of instabilityโ within the CDU-SPD coalition. โFriedrich Merz is unable to rally his own ranks. And that is the opposite of what this country needs. This country needs stability,โ she said.
She also called for new elections.
โWhat Iโm demanding is simply to clear the way. We should hold new elections. We need a stable government. And voters want a center-right government,โ she added.
The lack of votes is a major blow for Merz, who just prior to the vote had vowed to reform Germany. The BBC reported that former Chancellor Angela Merkel had come to the Bundestag to watch the vote take place.
โAs of tomorrow, you will have a government that is determined to move Germany forward through reforms and investments,โ Merz said on Monday after his full cabinet was unveiled.
By Owen Evans