A prominent critic of Boris Johnson has quit as a Government minister ahead of the result of the Tory leadership race, warning that Brexit had cast a “dark cloud” over the country.

In a sign of the difficulties Tory leadership favourite Mr Johnson could face in uniting a bitterly divided party, Sir Alan Duncan resigned from the Foreign Office before the new prime minister takes office.

Mr Johnson is widely expected to defeat Foreign Secretary Jeremy Hunt to become the Tory leader when the result of the contest is announced on Tuesday.

In his resignation letter, Sir Alan said he had “served with two very different Foreign Secretaries” – Mr Johnson and Mr Hunt.

Sir Alan said: “The UK does so much good in the world.

“It is tragic that just when we could have been the dominant intellectual and political force throughout Europe, and beyond, we have had to spend every day working beneath the dark cloud of Brexit.”

Boris Johnson
Boris Johnson leaves his office in Westminster on Monday (Kirsty O’Connor/PA)

His resignation will not be the last, with Chancellor Philip Hammond and Justice Secretary David Gauke having already confirmed they will quit rather than be sacked by Mr Johnson.

Sir Alan has been one of Mr Johnson’s fiercest critics on the Tory benches.

In June he described Mr Johnson as a “circus act”, and last year promised to end the former foreign secretary’s political career over his comparison of Theresa May’s Brexit deal to a “suicide vest”.

Sir Alan’s move was criticised by former minister Greg Hands, who said it would make a Jeremy Corbyn-led Labour government more likely.

Mr Hands, who is backing Mr Hunt, said pre-emptive ministerial resignations “in case your own democratically-elected party leader is not to your liking are absurd”.

Sir Alan’s resignation came after Mr Johnson restated his firm intention to get the UK out of the European Union by the end of October, claiming a deal with Brussels could be reached if the country has the “will” and the “drive” for Brexit.

The former foreign secretary said if it was possible to get to the moon and back 50 years ago then the problem of frictionless trade on the Irish border could be solved.

On the eve of the leadership ballot closing, Mr Johnson – who is widely expected to become prime minister on Wednesday – said it was time the country rediscovered its “sense of mission”.

He wrote in the Daily Telegraph: “If they could use hand-knitted computer code to make a frictionless re-entry to Earth’s atmosphere in 1969, we can solve the problem of frictionless trade at the Northern Irish border.

“There is no task so simple that government cannot over-complicate if it doesn’t want to do it. And there are few tasks so complex that humanity cannot solve if we have a real sense of mission to pull them off.

“It is time this country recovered some of its can-do spirit. We can come out of the EU on October 31, and yes, we certainly have the technology to do so. What we need now is the will and the drive.”

(PA Graphics)
(PA Graphics)

Mr Johnson claimed there were “technological pessimists” who think such a solution is impossible.

But he said: “There is abundant scope to find the solutions necessary – and they can and will be found, in the context of the Free Trade Agreement that we will negotiate with the EU (and this is common to both candidates in the current leadership contest) after we have left on October 31.”

The ballot of Conservative Party members will close at 5pm on Monday, with the result due to be announced on Tuesday morning.

Mrs May will tender her resignation to the Queen after taking Prime Minister’s Questions in the Commons on Wednesday afternoon, with the new Tory leader set to enter Number 10 soon after.