Sonia Khan left Downing Street in dramatic circumstances.

The former adviser to Chancellor Philip Hammond had been retained by his successor at No 11, Sajid Javid.

But the Met Police issued a statement on Friday confirming that on Thursday night "a police officer stationed at the door of No 10 Downing Street escorted a woman from the front door to exit gates as she did not have a security pass at the time".

Security clearance had been withdrawn from Ms Khan after she had been summoned to a meeting with the prime minister's senior adviser and de facto chief of staff Dominic Cummings.

There appears to be an informal investigation being conducted into the leak of the Operation Yellowhammer documents - commissioned under the previous regime at Downing Street - setting out the potential consequences of a no-deal Brexit.

A Downing Street source had previously pointed the finger at an unnamed former minister for the Yellowhammer leak - prompting Mr Hammond to write to Boris Johnson to "acknowledge that no former minister could have leaked this document" and "to apologise for the misleading briefing from No 10".

More widely, though, there is less tolerance of even low-level leaks since Mr Johnson took over as PM.

At the meeting with Mr Cummings, Ms Khan handed over both her personal and work phones, and her phone logs were checked.

There was evidence she had been in touch with former colleagues who had worked for Mr Hammond.

However, there was no evidence that Ms Khan had been involved in leaking any sensitive government information.

Dismissal

No reason was given for her dismissal, but it has been suggested the issue was whether she could be trusted to be transparent with No 10.

The BBC understands that Mr Javid has voiced his anger about the sacking, and a Whitehall source said this was an "unhelpful political row" between the chancellor and Boris Johnson, which was a "distraction from what the two men wanted to talk about - more funding for public services".

This incident follows the recent departure of another of Mr Javid's advisers and a female former adviser to cabinet minister Gavin Williamson who had moved to No 10.

A former minister told the BBC he believed the latest dismissal was "ultra vires" and in conflict with the Ministerial Code, as staffing matters should be the responsibility of the relevant minister - in this case, the chancellor.

But Whitehall's code of conduct does allow the prime minister to withdraw consent from the appointment of a special adviser by one of his ministers.

This happened to Mr Johnson himself as foreign secretary, when Prime Minister Theresa May's team blackballed Will Walden - the former BBC journalist who had worked for Mr Johnson at City Hall.

And it is understood the PM has also blocked some of his cabinet ministers from making their first-choice appointments.

One insider says the bigger picture is that, with Downing Street under new management, the disciplinary process has to be reset - and that the gender of those who have left is irrelevant.

After a period marked by resignations and rebellions in the last days and weeks of Mrs May's tenure, there has been a renewed focus on getting a grip on government.

Those who have not quite realised the ground rules have changed have found they are being forced to change careers.