There is a moral in the story of how Boris Johnson comes at last to be running the country.  For time out of mind, his critics have argued that his priority is to become Prime Minister, rather than do anything much that would deserve him the office.  He is, they have variously claimed, “an adulterer, a liar, a conniver in abortion, an accomplice in violence, a seeker of gagging orders, a serial underachiever, and a man bereft of political principle: a cynic in a jester’s cap who strikes comic poses while picking our pockets – who wants to have his cake and eat it” (in the words of our recent summing-up of their view).

ConservativeHome has never been convinced by this charge-sheet.  Johnson is not the only MP to want to be Prime Minister, let alone to be less than a counsel of perfection.  Furthermore, he twice won election as Mayor in a Labour-leaning city, thus gaining the biggest electoral mandate of any British politician.  He was a solid and popular Mayor who cut his council tax bill, delivered 100,000 new homes (not enough, but more than his Labour predecessor), created 25,000 new apprenticeships (ditto), pushed for Crossrail and tube extensions (which he got), and flew the flag for the capital with panache – not least, as we remember during these medal-winning days, during the 2012 Olympics.

None the less, that charge-sheet against him sapped his legitimacy, at least in the eyes of some Party members.  But in the wake of the EU referendum, his position has been transformed, for two main reasons – one confined to supporters of Brexit; the other applicable more widely.

First, Britain might not be leaving the EU were it not for Johnson.  There is a school of thought that holds that the British people would have voted for Brexit whatever the Remain and Leave campaigns did or didn’t do.  Admittedly, this cannot be disproved (one can’t prove a negative).  But the case is flimsy, and the same people who make it would have complained had there been no Leave campaign at all.  There was one.  Johnson was its main public face.  And Britain voted to Leave.  There is a sense in which he ended up sacrificing his main goal, his leadership ambitions, for a subsidiary one, Brexit.  But wherever the truth may lie, the country is in his debt.

Second, Michael Gove’s decision to withdraw support for Johnson’s leadership campaign, and run himself, put the latter in the unusual position of holding the moral advantage, or at least being seen to.  This is not to say that the former Justice Secretary acted dishonourably or even wrongly.  But that the two men had a deal and that Gove ended it has had the curious effect of casting Johnson as a wronged man.  That he reacted to the former’s decision wisely (by rapidly withdrawing from the contest) and calmly (in his speech at what would have been his launch) has buttressed this impression.

Indeed, what happened has left him a winner.  Gove has gone out of Cabinet, while he himself has come in, and to one of the most senior posts available, to boot; to one insulated from public criticism – relatively speaking – and arguably the most imposing: as grand as the Locarno Suite itself.

Yes, it is as Foreign Secretary that Johnson, this morning, finds himself the most senior Minister in Britain, since both the Prime Minister and the Chancellor are on holiday.  Only by having had his ambition frustrated is he able today to get a glimpse of what it would be like to have it realised in practice.  He can build on that thought.  For only by working by diligently away in King Charles Street does he stand even a chance of managing the transition, in some dim and distant future, to Downing Street.  And making a success of the Foreign Office is his most likely route to being remembered as a politician of real substance, since it is the most senior post he is likely to occupy.

There is so much to do.  The Foreign Office has been in decline since at least the New Labour years, when Tony Blair over-rode its institutional disquiet over war with Iraq – and, later, second-guessed it by appointing his own special envoy to the Middle East, and running policy towards that region from Downing Street himself.  David Miliband closed the foreign office language school.  Embassies shut abroad. The department’s language skills declined.  Its library was dismembered.  William Hague’s arrival and reform programme returned to the Foreign Office prestige and purpose.  But its effectiveness had been severely damaged.

Now on top of all that comes Brexit.  The referendum vote has come as a body-blow to the department.  Since the era of Con O’Neill, John Robinson and Michael Palliser – at the time of the Macmillan Government’s push to enter the Commons Market – belief in Britain’s place in the European enterprise has been a non-negotiable principle of departmental belief.  But the Foreign Office is losing an empire without necessarily finding a role.  It is Johnson’s mission to find it one.  Downing Street’s view is clear.  It wants the department to return to its traditional diplomatic function, and recover its expertise about developments abroad and what they mean for Britain.

Whatever the rights and wrongs of the spat between Liam Fox and Johnson over trade, it certainly makes sense for the the latter to concentrate on continuing the work that Hague started.  He could do a lot worse than call in his Ministerial colleague Rory Stewart, who pursued the department’s languages decline as a backbencher.

In short, the bigges items in the new Foreign Secretary’s in-tray are to ensure that we have diplomats in place who speak the languages of the countries in which they’re stationed; that the department has enough specialists in place to give it an understanding of what is going on in (say) the Far East and Latin America, and that it helps to carve out a new post-Brexit international role for Britain as a member of the UN Security Council, the G8, NATO, the Commonwealth; the possessor of the fourth-largest defence budget on the planet and of enough soft power to top international leagues – not to mention the English language, and the great global city of which he was once Mayor.

Above all, perhaps, Johnson has to get the country’s policy towards Russia and perhaps above all China into proper shape.  In the wake of the row over Hinckley Point, Britain’s approach to the latter is confused.  Do we see China as a strategic partner – a big investor in a country that badly needs investment – or as a threat to our security?

For all his history of clowning, faux pas and, er, lively quotes about foreign leaders (he once likened Hillary Clinton to “a sadistic nurse in a mental hospital”), the country could do a lot worse than have in charge of its foreign policy this “one man melting pot”, with his outward-looking interests, projection, and intuitive intelligence.  Johnson doubtless still wants to run the country in some distant day.  But he knows well that his best means of doing so now – and in future – is to get on with the day job.