(Bloomberg) -- Angela Merkel installed an ally at the head of Germany’s governing party, notching a victory at the end of a tumultuous political year and boosting her chances of serving out her fourth and final term.

Christian Democratic Union delegates chose Annegret Kramp-Karrenbauer, a moderate party insider largely aligned with Merkel’s world view, over BlackRock Inc.’s Friedrich Merz in a runoff ballot by 517 votes to 482. She’ll be the second woman after Merkel to lead the party, having handed the male-dominated old guard a defeat.

While underscoring a growing polarization of German politics that hasn’t spared the CDU, the close ballot also marks a vote of confidence in Merkel’s approach after 13 years as chancellor and allows her to focus on her legacy.

“What is close to my heart is that in the last parliamentary term of my political career I’ll be able to make a contribution that allows the renewed success of the CDU while maintaining our interests in matters of state,” Merkel said in her speech at Friday’s convention, rattling off challenges from the euro to plastic polluting the seas as worthy of her attention.

Looking Ahead

Kramp-Karrenbauer, 56, now is first in line to run for chancellor in 2021 after Merkel announced in October that her fourth term will be her last. If Merkel, 64, decides to step aside early, she’ll have an ally at her side to manage the transition.

“At some point, the two women will put their heads together and work it out among themselves,” Thomas Heilmann, a CDU lawmaker, said in an interview.

Merz was backed by former Finance Minister Wolfgang Schaeuble, both of whom now have been defeated twice by Merkel in major party votes over the past two decades. That’s as good an indication as any of the political staying power that has made Merkel Europe’s longest-serving leader.

In what turns out to have been a clever tactical move, Merkel promoted Kramp-Karrenbauer to CDU general secretary in February. The woman known in Germany as AKK sold her candidacy for party leader as an extension of her mentor’s big-tent strategy that’s kept the CDU in power since 2005.

Merkel’s Playbook

Kramp-Karrenbauer hails from the state of Saarland, a rural region near the French border that’s struggled with the transition from heavy industry. As state premier, she reached across the aisle and partnered with the Social Democrats, who govern with Merkel in a “grand coalition” in Berlin.

Kramp-Karrenbauer said during the leadership campaign that she wants to move the CDU forward from what she called the “leaden times” of recent months. She signaled she wouldn’t discard Merkel’s accommodating migration policy, while vowing to restore public trust “step by step.”

To contact the reporters on this story: Arne Delfs in Berlin at adelfs@bloomberg.net;Patrick Donahue in Berlin at pdonahue1@bloomberg.net

To contact the editors responsible for this story: Ben Sills at bsills@bloomberg.net, Iain Rogers, Tony Czuczka

©2018 Bloomberg L.P.