How surprised would you be if Ed Miliband, three years on from his resignation as leader of the Labour Party, entered the race to be the next mayor of Warsaw? If Boris Johnson fails to take over the leadership of the Tory Party from Theresa May, might he, just possibly, fancy himself as mayor of New York?

Last month, Manuel Valls, who served as prime minister of France under the Socialist President François Hollande, dropped something of a political bombshell when he announced that he was giving up his seat in the Assemblée Nationale to stand as mayor of Barcelona.

As it happens, Valls (56) was born in the Catalan capital, where his grandfather, a left-wing newspaper editor, fell foul of both the Fascists and the Far Left during the Civil War. His father, Xavier Valls, was a successful artist, who, like Picasso, moved to France to further his career. Luisangela Galfetti, his mother, is Swiss-Italian and a sister of the celebrated architect Aurelio Galfetti.  Brought up to speak both Catalan and Spanish, as well as Italian, Valls was educated in Paris, where, after serving in the army and taking French citizenship, he graduated in history from the Sorbonne.

His political life began in 1980, aged 17, when he joined the Young Socialist Movement and campaigned for Michel Rocard, who, after failing to make it to the Elysée, served as prime minister under François Mitterrand.

Valls dug in after that, rising to become mayor of Évry – where his renovation programme secured him the biggest percentage vote of any Socialist major – and deputy president of the Île de France region surrounding Paris. At the same time, he became a confidante and advisor to various party luminaries, including Hollande and his sometime partner Ségolene Royal.

In 2012, following his election as President, Hollande rewarded his lieutenant’s loyalty by making him minister of the interior and, two years later, prime minister. The regime, however, was doomed. Islamist attacks on Paris left hundreds dead, and the resulting loss of public confidence, combined with the impact of a slowdown in the economy and the failure of his own attempts to introduce reforms of the labour code, persuaded Valls that it was time to bail out.

It was his misfortune that just as he was presenting himself as the face of a less dogmatic, Blairite approach to Socialism, Emmanuel Macron burst onto the scene. In the ensuing 2017 presidentials, Valls was humiliated, losing to the old-school Socialist Benoît Hamon in the Leftist primary only to see Benoit come fifth in a first-round won with ease by Macron.

Even then, Valls’s French ambitions were not entirely extinguished. In the parliamentary elections that followed Macron’s second-round landslide, Valls won a seat as a New Left Socialist in the Assembly and waited – and waited – for the new President to take pity on him and appoint him to a senior government position.

Macron did not oblige. Either he felt that Valls, with his years of experience in the upper echelons of power, would be too much of a rival for the affections of his new party, La République en Marche, or, just as likely, he regarded him as a spent force, of no use to him in the revolution ahead.

From time to time, Valls would make a speech or suggest a new approach on issues of the day. But his words fell on deaf ears, so that he cut a sorry, isolated figure on the red benches. It was around this time that events in his native Catalonia claimed his attention. Barcelona and Madrid were on a collision course, with the provincial government of Carles Puigdemont demanding independence and the Spanish premier Mariano Rajoy determined to resist.

Events took their course. Rajoy, with the support of most of Spain, won the argument and Puigdemont and his cronies were deposed and forced to flee. New elections brought a more pragmatic proponent of Catalan independence, Quim Torra, to power, leading to an uneasy peace marked by uncertainty and resentment.

 It is into this vacuum that Valls has now stepped. As mayor of Barcelona, he would, with one bound, become one of the most high-profile politicians in Spain. As an advocate of Spanish unity, albeit in favour of enhanced autonomy for the region, he could hope to win favour not just in Madrid but in the upper councils of the European Union.

It will not be easy, though. He faces a tough six months until the mayoral elections next spring. Hardened veterans on both sides of the debate will cast him as a carpetbagger bent on relaunching his flagging career. If he makes it against the odds – and there is no doubt that he retains a measure of celebrity status – his name would make headlines across national frontiers. With its three million inhabitants, Barcelona is the second city of Spain, as well as the capital of Catalonia, and increasingly a global metropolis. Even if all he achieved was an efficient administration at a particularly difficult time, he could be judged to have proved himself and defied his critics.

This week, he told the National Assembly in Paris that he was quitting France “without bitterness or regret”, and with the exception of the Far Left’s Jean-Luc Melenchon, who accused him of betrayal, the reception he received from colleagues was both sympathetic and supportive. It is said that Macron – whom he had previously advised of his decision – was among the many who wished him good luck.

“I leave with a quiet heart and a calm soul because of all that I have tried to do and because I know that what I am going to do in Barcelona is very much what I have defended here – a certain idea of democracy and a certain idea of Europe. It’s a warm and tender goodbye, I’ll come back regularly.”

If he fails, he can of course always put himself forward as mayor of Lugano, his mother’s home town in Switzerland.