HAMBURG, Germany — Germany’s Christian Democrats elected Annegret Kramp-Karrenbauer, a moderate former state premier, as their new leader, signaling that despite an underswell of discontent over Angela Merkel’s recent stewardship, the country’s largest party does not intend to break with her centrist policies.

At a party congress in this port city on Friday, Kramp-Karrenbauer, the CDU’s secretary-general, won 517 votes in a run-off ballot, defeating Friedrich Merz, who received 482 votes. Health Minister Jens Spahn was eliminated in the first round.

Though the CDU and its Bavarian sister party have suffered dramatic declines at the ballot box in recent months, their center-right bloc known as the Union, which has led Germany for 50 of the past 70 years, remains the country's dominant political force. With her victory, Kramp-Karrenbauer, 56, not only became CDU leader, she also became the favorite to succeed Merkel as chancellor.

“This momentum must continue and it must be combined with the goal that unites us all — namely to make sure the Union — with all wings, with all members, with all those who hold responsibility — remains the great, common Volkspartei of the center," she said after her victory, using the German term for a big-tent political party.

The result will be welcomed in major European capitals and Brussels, where officials worried that a Merz win would have triggered an early end to Merkel’s chancellorship. At a time when Europe faces multiple challenges from the rise of populism to Brexit, Merkel is regarded across the region as an anchor of stability.

The tight result of the vote reflected a split in the CDU over the party’s direction.

“We need her in these difficult times for Europe,” Joseph Daul, president of the European People’s Party, to which the CDU belongs, told the convention before the vote.

Indeed, though the vote was close, it was a vindication of Merkel and her long record as party leader. While the chancellor did not endorse any candidate in the leadership race, Kramp-Karrenbauer — sometimes known as AKK — was widely seen as her favorite.

A victory by Merz, an old Merkel rival and critic who pledged to move the party to the right, would have amounted to a rebuke of her 18-year tenure as party leader, making it difficult for Merkel to stay on through the end of her term as chancellor in 2021, as she has made clear is her preference.

At the same time, the tight result also reflected a split in the CDU over the party’s direction. For years, conservatives have complained that Merkel’s centrist course diluted its traditional profile, whether on questions of identity and culture or economics. That internal conflict reached fever pitch in the aftermath of the refugee influx of 2015, which spurred a backlash against the chancellor, culminating in her decision in October to step back from the party chairmanship.

Merkel never apologized for her decision to keep Germany’s borders open, a fact her critics say fueled the rise of the far-right Alternative for Germany (AfD).

Deep divisions

Though some hoped the open leadership contest — rare in a party that has had only three chairpersons since 1973 — would heal the divisions, the process appears to have made them even more pronounced.

In the run-up to Friday’s vote, the three candidates toured Germany, holding regional conferences — a soft debate format that allowed party members to pepper the potential leaders with questions.

The tenor of those discussions was often critical of the status quo and the audiences of mostly older men seemed to favor Merz.

Nonetheless, polls showed the public at large strongly backed Kramp-Karrenbauer, a former premier of the Saarland region in southwest Germany.

"If we have the courage, we will take brakes off people who want to do something in this country" — Annagret Kramp-Karrenbauer

It was up to the 1,001 delegates in Hamburg, 999 of whom cast ballots, to resolve that disconnect. In the final days before the vote, it became clear that the victor’s first order of business would be to reunite the party.

Wolfgang Schäuble, the former finance minister and the CDU’s éminence grise, broke with leadership’s unspoken protocol by openly endorsing Merz, his one-time protégé. That prompted Kramp-Karrenbauer’s allies, including Economy Minister Peter Altmaier, to make their own preference known.

The last-minute posturing added to Friday’s drama.

Before the vote, Merkel and the three candidates all addressed the convention.

While she stopped short of openly supporting Kramp-Karrenbauer, Merkel urged the party not to veer from her course.

“We need to preserve what makes us strong,” she said.

In the run-up to the convention, commentators speculated that Merz’s best chance to win was to deliver a rousing speech that would draw undecided delegates to his cause.

On that front, he largely failed. Though Merz has a reputation as a skilled orator, it didn’t show on Friday. His convention speech was technical, defensive and flat.

In contrast, Kramp-Karrenbauer defied expectations with a feisty and upbeat speech that called on the party to have the courage to change while remaining anchored in the political center. She listed a range of challenges facing Germany, from "egoists and autocrats" abroad to threats to European unity. But, she said, the CDU could rise to the occasion.

"The answer isn’t in the stars, the answer lies with us," she said, urging the party to come up with new ideas and embrace innovation.

"If we have the courage, we will take brakes off people who want to do something in this country," she said. “The natural think tank of politics must be a Volkspartei like the CDU.”

Merz's missteps

Though Merz electrified the party when he first announced his candidacy, he made several missteps along the way. He characterized himself in an interview as "upper middle class," despite his million-euro annual income. He also created a stir by questioning whether the right to asylum should remain anchored in the German constitution and angered some party members by saying that many in the CDU accepted the AfD's rise with "a shrug."

Kramp-Karrenbauer won the first round of Friday's election with 450 votes, 50 short of the 500 needed for a majority. Merz finished with 392 and Spahn with 157. But given that Spahn belongs to the party's conservative wing like Merz, it was far from clear that Kramp-Karrenbauer would win the necessary majority in the runoff.

Kramp-Karrenbauer broke into tears as the result was announced. Merkel, who glared during Merz’s speech, smiled broadly and took the stage alongside Kramp-Karrenbauer as the crowd cheered.

Merz's supporters had argued that Kramp-Karrenbauer wouldn't deliver the kind of renewal they believe the country needs. "This is bad for the CDU, bad for Germany and bad for Europe," one senior CDU official who supported Merz said after the result was announced.

Merz pledged to support Kramp-Karrenbauer and the party “if wanted.”

Sensing the necessity to end on a note of unity, Kramp-Karrenbauer called both Merz, who sat on his seat with his chin in his hand after the result was declared, and Spahn, to join her onstage as the cameras circled.

For Kramp-Karrenbauer to reach her larger goal of succeeding Merkel as chancellor, she’ll have to prove that Friday’s show of unity was more than a photo-op.

This article has been updated.