A close ally has been elected to succeed German Chancellor Angela Merkel as the leader of the country's center-right Christian Democratic Union.
Annegret Kramp-Karrenbauer, the party's current general secretary, narrowly defeated former Merkel rival Friedrich Merz 517 to 482 at a congress of the party Friday in Hamburg.
Merz sought to move the CDU further to the right.
A third candidate, Health Minister Jens Spahn, an outspoken critic of Merkel's 2015 decision to welcome more than 1 million asylum-seekers to Germany, was eliminated in a first round of voting.
The win by the 56-year-old moderate signaled the party's preference for stability over dramatic change.
Kramp-Karrenbauer is now tasked with trying to win back voters who have defected to the right and left.
Kramp-Karrenbauer's win also is a much-needed victory for the legacy of Merkel, who is stepping down after 18 years as the party leader.
In her farewell speech at the congress, Merkel thanked her staff and said the party "is never just one person by him or herself, but always all members together."
Merkel reminded fellow party members that experience has shown "how much strength and momentum we can develop" when faced with difficulties.
During her half-hour speech she received several standing ovations. Some delegates held up placards saying "Thank you, boss!''
Merkel announced in October she would not run for re-election as the party chairperson, but she planned to remain chancellor until the end of the current term ending in 2021. However, it is possible that elections could be called before then.
Merkel, 64, is stepping down after a series of polls have shown a decline in popularity because of her liberal refugee policy.
Merkel has led Germany since 2005, and has moved the CDU steadily toward the political center.