Tony Blair's second historic walk along Downing Street was nothing like the first. There was no Cherie Blair, no flag-waving crowd jostling to shake his hand, no theme tune like "Things Can Only Get Better". The mood in Westminster was "Let's Hope Things Get No Worse" as a grim faced group of politicians marched to the door of 10 Downing Street, led by a past and future Prime Minister.

But it would be wrong to underestimate his achievement. Here was a man who left office in 2007 unpopular in his party and the country at large. And his stock has hardly risen since: further revelations about his decision to take Britian to war in Iraq combined with outrage at the millions he has earned from often dubious sources have made him a hate figure across the political spectrum. So how did he end up back at No 10?

The extraordinary story of Tony Blair's return started on a precise date, 27 June 2012, when he confessed in the Evening Standard that part of him yearned to be back in Downing Street, in a job he had not wanted to leave.

Download the new Independent Premium app Sharing the full story, not just the headlines

Though his remark caused a flutter of interest at the time, the possibility that he could return to active politics – let alone into 10 Downing Street – seemed too remote to be taken seriously. It took an extraordinary chain of events – the swirling crisis in the euro, the long-running bank scandal, the strange language of the Chilcot report, a timely by-election, and the chaos that followed an inconclusive and ill-tempered general election – to turn a near impossibility to reality.

Some commentators criticised Tony Blair for making so complete a break with domestic politics when he resigned in 2007, but there were powerful reasons for him to turn his back on Parliament and party, including the need to put an end to the long saga of his rivalry with Gordon Brown.

Personal factors also came into play. The UK had never been governed by a Catholic. Tony Blair's religious beliefs were pulling him to Rome, a spiritual journey whose completion had to wait until he was out of office. Cherie Blair, with her childhood memories of financial hardship, wanted her husband to start making the sort of money that former prime ministers can make but serving prime ministers can't.

More seriously, it was assumed the Iraq war had inflicted damage to Tony Blair's reputation from which it could never recover. His comeback had to be delayed until Sir John Chilcot published the findings of his inquiry into the war. When the Chilcot report appeared in 2013, four years after the start of the inquiry, its conclusion was so convoluted that supporters and opponents of the war could equally claim vindication, while the rest of the country did not know what to make of it.

What stuck in the public mind was Tony Blair's demeanour on the day the report came out, which brought home to a forgetful public that this was one of the greatest political communicators of our age. Blair's often repeated line "I did what I believed was right when I believed it was right," was a good enough answer for a public that had largely forgotten what the Iraq war was meant to be about.

Then there was the heart attack that struck down a decent but obscure Labour MP, creating a vacancy not far from Blair's old seat in Sedgefield. The local party secretary wanted an MP who would put the constituency on the map. The region's two leading trade union bosses were hostile to Blair, but also loathed each another, eliminating any prospect of the unions combining behind a "Stop Blair" candidate. The rumour that he might be interested was meanwhile galvanising local party members, and once it had leaked into the national media, Ed Miliband knew he could not allow left-wing activists to be seen blocking the former Prime Minister's return to Parliament. Party organisers were discreetly instructed to ease Blair's passage. By the time the selection process started, it was basically all over. A local councillor and several party members noisily resigned and backed the Respect candidate, but it had no impact on the result.

Ed Miliband was also spared difficult decisions about how to fit a former prime minister into his shadow cabinet when Blair said that all he wanted was to be a backbench MP, making thoughtful speeches about world affairs. He never uttered a word that could be interpreted as disloyal to Ed Miliband, but his mere presence, with David Miliband often at his side, was enough to skew the internal dynamics of the Labour Party. And David Cameron's taunts about how "the best leader Labour has ever had is sitting in the back row saying nothing," though they achieved their immediate purpose of destabilising Ed Miliband, inadvertently added to Tony Blair's stature as a leader in waiting.

They also contributed to a highly personalised general election campaign. The sight of the three party leaders at each other's throats during the televised debates, arguing ferociously over the problems of the euro and the banking to which none had a convincing solution, were a poor contrast to the television shots of a smiling Tony Blair out on the street.

And yet, it was not the inter-party rivalries that finally projected Tony Blair back into Downing Street, but the unforeseen split that opened up among the Liberal Democrats. Having done better than expected in holding their seats, the Lib Dems came close to breaking into separate parties as one side flatly refused to go back into coalition with a depleted Conservative Party and the other was equally determined not to allow Ed Miliband and Ed Balls into Downing Street. The world's oldest parliamentary democracy was in danger of becoming the joke of the Western world as days dragged with no sign that anyone was capable of forming a stable government. It was somehow inevitable that as this crisis point, up popped Lord Mandelson, on the Andrew Marr programme, wringing his hands theatrically as he described how "friends" were "begging" Tony Blair to take up the burdens of prime ministerial office but he seemed "reluctant". No one who knew the spin master's mode of operating believed that he was doing anything but testing the water on Blair's behalf, but the performance convinced the public. Within 24 hours the "national conversation" about whether the nation should send for Tony Blair was in full throat. Radio phone-ins were heavily in favour, and one opinion poll showed an outright majority answering "yes" to the question "Would you support a coalition government led by Tony Blair?" None of the other names on offer scored above 20 per cent.

Finally, rather than allow the Cameron government to limp on until a new election in the autumn, Ed Miliband talked to reporters hanging around his house, knowing that they would ask him if he would accept office in a Blair Cabinet, and having made up his mind to answer "yes". The very next day, the man who had led Labour through three election victories was summoned to the Palace.

Tony Blair must have heard those shouts of "Ramsay MacDonald", from the demonstrators in Whitehall as he arrived in Downing Street. There is an undoubted parallel with the former Labour leader who headed the "National" government 80 years ago. In one respect, Tony Blair's situation is even more anomalous, because MacDonald was at least the acknowledged leader of an organised parliamentary group, albeit the tiny group of National Labour MPs. Blair is not, strictly speaking, anyone's leader. He is the first Prime Minister in modern times without a party at his command. Yet despite that, his position is vastly more secure than MacDonald's was. MacDonald was the prisoner of the Conservatives. Tony Blair is no-one's prisoner. Although he could not continue as Prime Minister without the support and good will of Ed Miliband and the Labour whips, he and the party exist in a state of mutual dependency. Neither can govern without the other. It is an incredible comeback for a man who turned his back on domestic politics only eight years ago.