Up until early Wednesday evening, Britain’s post-referendum political transfer of power appeared to be going remarkably smoothly. David Cameron managed a good-natured, jokey final prime minister’s questions session that also offered a brief respite to embattled Labour Party leader Jeremy Corbyn. Incoming Prime Minister Theresa May was photographed kissing hands with a beaming Queen Elizabeth before delivering a remarkably well received inaugural speech.

Britain's Foreign Secretary Boris Johnson addresses staff inside the Foreign Office in London, July 14, 2016. REUTERS Andrew Matthews/Pool

And then, news broke that Boris Johnson had been appointed foreign secretary.

After all the efforts to maintain a sense of control, consistency and message that Britain would now move towards Brexit in an orderly manner, that appointment strikes a wildly unexpected note. Foreign officials, analysts and journalists could scarcely believe it. Nor, I’m told, could many in Whitehall.

With his shock of unruly blonde hair and idiosyncratic, often politically incorrect utterances, Johnson has long been one of the more colorful figures in UK politics. In the aftermath of the referendum, he is more controversial still. Now, the man who compared Hillary Clinton to a “sadistic nurse in a mental hospital” is effectively Britain’s top diplomat. If May had been looking for a way to send a frisson of shock through the rest of the world, she could hardly have found a quicker way to do it. For all the global handwringing, it’s always been possible to make a coherent case for Britain quitting the EU. Following the referendum result, there was clear sympathy for May at her strategy of implementing the “leave” vote despite her own support for “remain.”

Appointing such an internationally polarizing figure as Johnson to the key foreign affairs role is harder to justify – although it will at least allow her to exert some direct control over the man who was at one stage her chief rival for the leadership.

One of the things that could be said in Britain’s favor since the June 23 vote is that it has faced the chaos and uncertainty since then with a pretty unflappable sense of humor. The risk, though, is that the rest of the world takes Johnson’s appointment –whatever he says and does once in office – as taking that too far.

The former mayor of London may well exceed expectations, however. Indeed, it is almost impossible that he will not, at least in short term. The Oxford-educated Johnson is amongst Britain’s more intellectually interesting politicians, and there has always been more to him than the bluster that the recent Brexit campaign might suggest. If nothing else, he has a keener appreciation of history than almost any of his contemporaries.

According to those who listened in, Johnson’s introductory remarks and conference call with British officials around the world was relatively well received. In his first public statements, Johnson acknowledged his appointment had “sent plaster falling” from the ceilings of foreign ministries around the world, particularly in Europe.

His focus, he said, was crafting a role for Britain still heavily involved in the world – including in Europe – once it had quit the EU. That’s a tough, challenging task – and Johnson will have his work cut out.

In general, the role of foreign ministers – or the secretary of state in the U.S. context – has become rather less important over the last two decades, with national leaders taking over the bigger conversations instead. At the State Department, John Kerry has found the agenda heavily dominated by the White House; significant quantities of his time are devoted to perceived second-tier priorities such as the Israeli-Palestinian conflict. When it comes to the important decisions, Johnson will almost certainly have little choice but to defer to May.

Still, perceptions are important. In Europe, in particular after the referendum, Johnson was already something of a toxic brand. Many European officials and analysts hold him heavily responsible for Britain’s decision to leave the union, accusing him of misleading voters and acting purely out of personal ambition. . As a “Daily Telegraph” journalist in Brussels in the 1990s, Johnson’s merciless, often exaggerated lampooning of EU regulations and institutions helped foster British euroskepticism. As London mayor, he had built a more positive reputation, but that was almost entirely destroyed by the referendum campaign – particularly when he backed down from running for Downing Street himself.

As foreign secretary, Johnson will not – perhaps fortunately – be primarily responsible for relations with the continent. Brexit negotiations will be led by newly appointed minister David Davis, presumably closely overseen by Downing Street. Like Johnson, Davis campaigned for “leave” but is perhaps a safer pair of hands – although he lacks ministerial experience. New trade minister Liam Fox – previously Defense Secretary until he resigned following a somewhat bizarre scandal involving a lobbyist – will also be key, although he is also a controversial choice.

May has placed delivering “Brexit” firmly in the hands of these three “leave” advocates, essentially challenging them to make good on their promises to the electorate. If they cannot get a good deal, it’s still not impossible to imagine her calling a second referendum – even though she has repeatedly ruled out such a move.

Johnson will be the point person for a host of other important relationships, particularly those involving major powers and emerging markets. In that respect, his penchant for sometimes off-color remarks or uncomfortable drifts toward racial generalizations could be unfortunate, to put it mildly.

Perhaps most important, however, will be relations with the United States. There Johnson’s appointment initially appears to have been poorly received. Already in Washington, there was a tendency – perhaps wrongly – to view the referendum vote as proof of the UK withdrawing from the world. Appointing Johnson as foreign secretary perhaps goes beyond that, seen by some in the foreign policy elite as signaling Britain just doesn’t take the rest of the world seriously. At the very least, Washington insiders say, it will make things “more interesting.”

Johnson has already managed to insult both presidential candidates and alienated the current White House with an ill-judged opinion column at the time of President Obama’s London visit. Relations with John Kerry will be key, but it seems unlikely the two men have an overlapping sense of humor.

There also very real policy differences. On Syria, Johnson has openly suggested cutting a deal with President Bashar al-Assad, an option Kerry and the State Department in particular seriously oppose.

This is unquestionably the most important job Johnson has ever done, and he must know that how he performs at it will likely define the rest of his political life. After everything that has passed, it is in many ways a second chance.

At his best, he can be charming, charismatic and genuinely amusing. In his new role, he is going to have to have to be more professional and credible than ever before.

If he isn’t, then Prime Minister May might already have made one of her greatest mistakes.