HAMBURG, Germany (AP) — Angela Merkel's center-right party elected an ally of the longtime German chancellor as its new leader on Friday, opting for continuity and experience as it handed her the challenge of opening a new chapter and improving the party's electoral fortunes.

Annegret Kramp-Karrenbauer, 56, narrowly defeated one-time Merkel rival Friedrich Merz to become the Christian Democratic Union's new chairwoman. The vote came hours after the party feted Merkel with a lengthy standing ovation as she wrapped up 18 years at the helm.

Merkel has said she plans to remain chancellor until Germany's next election, which is due in 2021 but could come earlier. Kramp-Karrenbauer, the CDU general secretary since February and previously a popular state governor, is now the favorite to run for chancellor in that vote.

That isn't automatic, but all but two of Kramp-Karrenbauer's seven predecessors as CDU leader became chancellor.

She was quick to call for party unity after defeating Merz 517-482 on Friday, saying "there is a place in this party" for Merz and Health Minister Jens Spahn, who was eliminated in a first round of voting at a congress in Hamburg.

Merz stood for a more conservative, business-friendly approach than Merkel, while Kramp-Karrenbauer — often known as "AKK" — was closer to Merkel's centrist stance. Kramp-Karrenbauer said she wants to ensure that the CDU avoids the fate of shrinking center-right parties in France and elsewhere.

"We're a bit like the last unicorn in Europe — the last big people's party that still exists," she told delegates before the vote. "I want that to be the case tomorrow too. This Europe, this Germany, this world needs a strong CDU."

Kramp-Karrenbauer has shown a greater willingness than Merkel to cater to conservative rhetoric, and on Friday rejected the notion that she would be a Merkel clone.

"I've read a lot about what I am and who I am — 'mini,' 'a copy,' 'simply carrying on the same way,'" she said. "I stand here as I am and how life has formed me, and I am proud of that."

She described herself as a mother of three "who knows herself how difficult it is to reconcile family and professional life" and listed her long experience in regional government.

Kramp-Karrenbauer was the first woman to be a German state's interior minister, or top security official, and served as the governor of western Saarland state, defying expectations to win re-election by a wide margin last year. In February, she gave up the governor's job to become the CDU's general secretary, managing the party's day-to-day political strategy.

In 18 years of experience, she said she "learned that leadership is more about internal strength then external volume." And she said the CDU must attract voters with its own ideas, not by competing to see "who attacks our political opponents the hardest."

In his speech, Merz highlighted the need to tackle the "intolerable" success of the far-right Alternative for Germany party and called for a more combative approach toward the CDU's rivals in the political center ground.

Merz, who was the CDU's parliamentary leader until he was pushed out of the job by Merkel in 2002, had sought a spectacular comeback in Friday's vote after a decade away from front-line politics.

Merkel has been CDU leader since 2000 and chancellor since 2005. She has moved her party relentlessly to the center, dropping military conscription, accelerating Germany's exit from nuclear energy and introducing benefits such as encouraging fathers to look after their young children. She also allowed the introduction of gay marriage, which Kramp-Karrenbauer was more vehement in opposing.

Most controversially, Merkel allowed in large numbers of migrants in 2015. Kramp-Karrenbauer has talked tough on immigration issues in recent weeks, but warned that endlessly rehashing the debate about Merkel's 2015 decision on migrants is a turn-off for voters

In her farewell speech as leader, the 64-year-old Merkel said Friday that "our CDU today is different from the year 2000, and that is a good thing."

For years, Merkel's popularity lifted the CDU and its Bavaria-only sister party, the Christian Social Union. In the 2013 election, they won 41.5 percent of the vote and only just fell short of an outright parliamentary majority.

At present, the center-right bloc is polling around or below 30 percent. Merkel's fourth-term governing coalition with the center-left Social Democrats has lurched through a series of crises since taking office in March, and the CDU has lost supporters both to the liberal Greens and to Alternative for Germany.

Merkel, however, recalled that the CDU was in a deep crisis when she took over in 2000, mired in a party financing scandal surrounding ex-Chancellor Helmut Kohl. She said it "kept a cool head" to recover.

"I wasn't born as chancellor or as party leader," she said. "I have always wanted to do my government and party jobs with dignity, and one day to leave them with dignity ... now it is time to open a new chapter."

Kramp-Karrenbauer said the competition to succeed Merkel "has given us lift." It was the first contested CDU leadership election since 1971.

"This upswing must continue," she said.

___

Moulson reported from Berlin.