When Francois Hollande tapped Emmanuel Macron as an aide in his 2012 presidential campaign, little did he know that he was taking advice from his eventual successor.
Nor could the French Socialist leader, who hands over power to Macron on Sunday, have foreseen that the liberal reforms championed by his protege would turn out to be his undoing.
At 62, Hollande leaves office on Sunday as one of France's least popular leaders after becoming the embodiment of his country's social and economic paralysis.
Hollande had an easy touch with the public but quickly acquired a reputation for being wishy-washy, with detractors nicknaming him Flanby after a French brand of wobbly pudding.
Vowing to govern as "Mr Normal", he took the helm five years ago on a wave of goodwill from voters eager to turn the page on the "bling-bling" years of the flamboyant, brash Nicolas Sarkozy.
But Hollande's term got off to an inauspicious start as rain drenched his inaugural parade and he flew into a thunderstorm on his maiden foreign trip, to Berlin.
Hollande set about implementing his left-wing agenda, vowing to "reverse the curve" of unemployment that had risen to around 10 percent in the wake of the 2008 financial crisis.
One of his crowning achievements was to shepherd France's gay marriage through parliament in 2013 despite mass protests.
He initiated a 75 percent "millionaire's tax", which caused an outcry among high-profile figures such as actor Gerard Depardieu and was quietly scrapped.
Then, with the jobless figures refusing to budge and the economy stuck at near-zero growth, Hollande came under increasing pressure to change course.
He began pushing for a tax cut on businesses in exchange for hiring pledges, known as the Responsibility Pact, triggering dissent on the Socialists' left flank.
Hollande brought in economic liberal Manuel Valls as prime minister in March 2014 -- and a certain Emmanuel Macron as economy minister that August.
Their push to reform France's ossified labour market turned the dissent into outright rebellion within the party and anger on the streets.
France saw waves of strikes and sometimes violent protests nationwide, with images of tear gas and hooded activists hurling petrol bombs beamed onto TV screens around the world.
Hollande's paralysis as president combined with revelations over his amorous peccadillos -- he was caught cheating on the woman he called the love of his life, Valerie Trierweiler -- dragged down his approval ratings.
Hollande won credit for his leadership throughout a series of jihadist attacks that have killed 239 people since 2015.
In one of the defining moments of his presidency, he led world leaders and one million Parisians in a march against terrorism after the January 2015 attack on Charlie Hebdo magazine and a Jewish store.
After the November 2015 attacks in the capital that killed 130 people, his government imposed a state of emergency that has been renewed repeatedly, over the objections of rights groups.
Despite his dismal poll ratings that at one stage plunged to just four percent, Hollande held out the hope that a late improvement in unemployment figures would justify a re-election bid.
It was a hope he continued to nurture after Macron walked out on the government and announced his own bid for the presidency.
"He knows what he owes me," he fumed after Macron launched his own En Marche movement.
Hollande's dithering on a second term was toxic for the Socialist Party.
Then a tell-all book came out in October that made many wonder if he was his own worst enemy.
In "A President Shouldn't Say That", a book of interviews by two journalists from Le Monde newspaper, Hollande heaped scorn on the national football team and even his own government's policies.
He finally bowed out of contention in early December, becoming the first president of France's fifth republic, founded 58 years ago, to decide not to seek a second term.
Hollande won the Socialist nomination for the presidency after then IMF chief Dominique Strauss-Kahn -- the hot favourite -- crashed out of the running after being arrested in New York on charges of sexual assault.
The criminal charges were dropped after Strauss-Kahn's accuser was found to be an unreliable witness, but the man known as DSK was forced to quit the International Monetary Fund and abandon his presidential ambitions.
Hollande's scandals were of a different order, less sordid but still sensational.
He split with fellow Socialist traveller Segolene Royal, the partner he never married though they had four children together, for the journalist Trierweiler.
Their stormy relationship ended after it emerged that he was enjoying trysts with actress Julie Gayet -- paparazzi famously photographed him arriving by motorbike at their Paris love nest.
Trierweiler's score-settling book "Thank You for This Moment: A Story of Love, Power and Betrayal", went on to become an international bestseller.