AFTER 18 years, Germany's ruling Christian Democratic Union has a new leader. Inside a conference centre in Hamburg the party chose Annegret Kramp-Karrenbauer to succeed Angela Merkel, who remains Germany's chancellor, at least for now. After delivering a passionate speech in which she promised to restore the party's flagging fortunes, Mrs Kramp-Karrenbauer (widely known as "AKK") duly defeated her main challenger, Friedrich Merz, securing 517 votes of the party's delegates to his 482 on the second round.

Ms Kramp-Karrenbauer takes over a party that was in dire straits six weeks ago. Dreadful state election results, sagging poll numbers and the troubled state of its coalition with the Social Democrats (SPD) had sapped morale and boosted calls for Mrs Merkel to step down. Yet her decision, on October 29th, to resign as party leader but stay on as chancellor may have done enough to satisfy the appetite for change. The month-long campaign, the first genuine contest for the CDU leadership since 1971, seems to have reinvigorated the party. After almost two decades under Mrs Merkel, the CDU was hungry for competition.

Ms Kramp-Karrenbauer, a close ally of Mrs Merkel, now becomes the favourite to lead the CDU into the next general election, though that may depend on her ability to revive the party’s fortunes in a series of state elections due next year. A low-key campaigner who can struggle to hold a room, she is nonetheless a proven vote-winner, having run Saarland, a tiny state bordering France, between 2011 and 2018. Her campaign for the party leadership was free of missteps, unlike her rival Mr Merz's.

Her biggest challenge during the campaign was shaking off her "mini-Merkel" reputation. The two women share a down-to-earth style and an instinct for consensus, but there are important differences between them. Mrs Kramp-Karrenbauer is an economic centrist, backing Germany's minimum wage; but her social views are infused with a Catholic conservatism. She is anti-abortion, casts a sceptical eye on gene-editing techniques, and has compared gay marriage to polygamy and incest. She backed Mrs Merkel's controversial refugee policy but was not especially liberal at home: her Saarland government subjected some refugees to compulsory X-rays to determine their age. On foreign policy her instincts are Francophile, as befits a Saarlander (she speaks the language well), but during the campaign she had less to say on foreign affairs than Mr Merz.

Mrs Merkel was the other victor today. Earlier this year the chancellor unexpectedly appointed Ms Kramp-Karrenbauer CDU secretary-general, a clear sign that she had finally chosen a successor. That sparked concern from some party elders unhappy with the prospect of continuing Mrs Merkel's centrist approach, notably Wolfgang Schäuble, a former finance minister now serving as president of the parliament. They threw their weight behind Mr Merz, a pro-business former party parliamentary chief. But their faction narrowly lost out.

That leaves some fearing a mini-insurgency inside the party. Towards the end of the campaign CDU grandees started to worry about the aggression of some Merz supporters, especially on social media. Katja Leikert, a CDU MP from near Frankfurt who backed Ms Kramp-Karrenbauer, says some Merz-supporting members of her local party will probably quit in protest. She fears similar developments elsewhere in Germany.

That cannot be ruled out. Yet Mr Merz's concession speech was gracious, and the CDU has a good record of uniting behind its leaders. The good relationship between Ms Kramp-Karrenbauer and Mrs Merkel suggests a productive division of labour in the months ahead: the CDU leader can focus on party matters while the chancellor devotes herself to policy and elections. Mrs Kramp-Karrenbauer will also seek to placate her opponents inside the CDU. In a short victory speech, she urged Mr Merz and Jens Spahn, the other defeated candidate, to work with her.

As for Mrs Merkel, whether she can fulfil her wish to remain in office until the parliamentary term expires in 2021 may depend less on her own party and more on the SPD, which is tanking in the polls and visibly unhappy in government. It might well withdraw from the coalition next year if it performs badly in European and state elections. If so, Ms Kramp-Karrenbauer may find herself back on the campaign trail rather sooner than she expects.