German Chancellor Angela Merkel on Friday gave an emotional farewell speech to her ruling Christian Democrats (CDU), as she stepped down as party leader.
"Our liberal values must be defended, internally and externally," she said.
She hinted that she was backing Annegret Kramp-Karrenbauer to succeed her, praising her electoral performance as chief minister of Saarland.
Despite quitting as CDU leader Merkel plans to remain German chancellor until her term ends in 2021.
Kramp-Karrenbauer's chief rival in Friday's CDU vote is millionaire corporate lawyer Friedrich Merz.
The third candidate, health minister Jens Spahn, appears to have less chance of winning.
Merkel's speech was punctuated by applause and she got a standing ovation of more than six minutes at the end. CDU delegates at the congress in Hamburg also held up signs saying "Thanks boss".
Then the conservative party paid tribute to Merkel, 64, with a video showing highlights from her 18-year CDU leadership. The soundtrack was the 1960s hit Days, by The Kinks.
Merkel was first elected chancellor in 2005 and is not seeking a fifth term beyond 2021.
In her speech she warned of tough challenges ahead, including climate change, maintaining European unity and coping with Brexit.
She reminded the CDU of other electoral successes last year, avoiding mention of this year's setbacks in state elections, which were heavy blows for her.
"I don't need to be party chairman to remain bound to this party. And I'm still chancellor," she said.
She stressed that the CDU stood for human dignity, and praised the late US President George Bush Senior and late German Chancellor Helmut Kohl for reuniting Germany in 1990. She was at the funeral of George HW Bush on Wednesday.
Speaking of the end of the Cold War, she told the CDU that "at that decisive time he [Bush] trusted Chancellor Kohl... he understood how politics must serve everyone".
She expressed "overwhelming gratitude" for having had the role of CDU leader. "The future will test our values... we must always approach work joyfully," she said.
Who wants Merkel's job?
Annegret Kramp-Karrenbauer - known as AKK, the Merkel choice
The 56-year-old former prime minister of the state of Saarland was appointed CDU general secretary earlier this year and is the party favourite, polls suggest. Popular in Saarland and Berlin, she has an unpretentious style and a reputation for calm analysis, as well as political acumen.
Her greatest strength is also her greatest weakness; she is a Merkel loyalist, perceived as someone who will replicate much of the chancellor's style and policy.
Friedrich Merz - former top party figure, sidelined by Merkel
The millionaire businessman was a powerful player in the CDU in the early 2000s but left politics when he fell out with the chancellor.
Since then, the 63-year-old lawyer - who has strong links to America - has built a career in the private sector and works for US investment firm Blackrock. He appeals to the more conservative and business-minded wing of the party and has the official backing of ex-Finance Minister Wolfgang Schäuble.
Jens Spahn - young and energetic but unlikely to win
The health minister is ambitious and, aged 38, the youngest of the three candidates.
A former banker, he was once described by Schäuble as "one of the great hopes for the future of our party".
But Spahn has ruffled feathers in the party and in the cabinet. Sharply conservative, Catholic and gay, he is a divisive figure for many.