The candid thoughts of some of Britain’s most senior diplomats on how the country is viewed around the world following the Brexit vote are revealed in a BBC series capturing life inside the Foreign Office.

The three-part documentary, filmed over more than a year following last year’s general election, shows the diplomatic service grappling with sometimes difficult international relations during the Brexit negotiations, a task described by the Foreign Office’s chief civil servant, Sir Simon McDonald, as “the biggest thing we have ever undertaken in peacetime”.

The series captures one meeting earlier this year attended by senior diplomats in which the British ambassador to Brazil, Vijay Rangarajan, says the Brazilian government “don’t understand Brexit … [but] they think, bluntly, that we will be so desperate for a trade deal we will sign up to a trade deal on their terms”.

McDonald tells those present that while some are trying to stop Brexit, “my judgment is this is a failing course … I think the course is set”. But Dame Barbara Woodward, Britain’s representative in China, says there is active discussion there of the possibility of a second referendum. “The Brexit debate is very, very live in China, and the world has changed around us, because the China-US relationship has become much more important.”

The documentary covers the period of Boris Johnson’s time as foreign secretary and his resignation and replacement by Jeremy Hunt in July. Filmed on his ministerial plane en route to a visit to Lisbon and Paris last October, Johnson asks civil servants why the French are “trying to shaft us” during the Brexit negotiations.

Caroline Wilson, the Europe director, tells the then foreign secretary: “We think they maybe feel that they could contribute to work with us on the global strategic issues, while seeking to get advantage on economic issues, possibly, in the near future.”

“We need to be realistic,” says Johnson. “They won’t cut us any slack, we should be prepared to walk away.”

“You can be prepared to walk away, foreign secretary,” replies Wilson.

In a discussion with embassy staff in Portugal, Johnson says of Brexit: “I’ve never known a bigger apple of discord be thrown into British life. It’s just been … aaaargh.” But while there was always going to be “a slightly scratchy period while we worked out how to do this, it will be fine once it’s done”.

In an implicit criticism of his colleagues conducting the Brexit negotiations, Johnson says: “To be honest, it hasn’t helped this sense of division that it’s taken so long to get going. That is bad. We need to move on.”

The film captures the annual gathering at the Foreign Office of all of Britain’s ambassadors, during which McDonald compares Britain’s position in the Brexit negotiations with that of Germany in 1919 after the first world war and France at the end of the Napoleonic wars in 1815. “What those things have in common is a major European power troubling other European powers, and those powers having to do something about it.”

The role of the diplomatic service was to help convince other European countries not to “exploit the full strength of their position” in relation to Britain, he tells them, and to be “generous” with the UK. “I hope you agree that is an interesting challenge to have.”

The work of the Foreign Office will become more difficult following Brexit, McDonald tells the filmmaker Michael Waldman, because “we will no longer be in the room when EU member states are deciding the big issues. So we are going to be doing this work by ourselves. And we will be working harder.”

The film argues that as Brexit approaches, “apparent backwaters” are becoming more significant to Britain’s foreign interests; Waldman travels to Mongolia, which has a population of 3.1 million, to see the British ambassador helping to broker deals with the country’s lucrative mining industry. McDonald mentions Botswana as an example of a country where small resources might yield diplomatic results.

Inside The Foreign Office starts on BBC Two on Thursday 15 November at 9pm.