Mayor Sadiq Khan felt compelled to act after a delegation of families went to City Hall to call for her to go.
He was concerned that the brigade was at risk of losing the trust of Londoners. He said the decision to remove her from the £202,000-a-year post was “the right one”.
Ms Cotton’s departure was immediately welcomed by survivors’ group Grenfell United, which said it would help to “keep Londoners safe”.
In October, Ms Cotton was criticised for “remarkable insensitivity” for telling the Grenfell Tower public inquiry last year that she would not have done anything differently in terms of how the brigade responded to the June 2017 fire that killed 72 people.
She will leave the London Fire Brigade on December 31, four months earlier than planned. She had announced in June that would retire aged 50 next April after 32 years’ service.
A brigade statement said that she was stepping down “in consultation with City Hall”. It is understood she had wanted to remain in post until next April, but will be retiring “in accordance with her contract” and will be paid her salary up until April.
Her pension, which she is legally entitled to receive as a result of payments into the scheme and reported to be worth £2 million, is unaffected.
Labour MP David Lammy, whose friend Khadija Saye died in the fire, former Tory fire authority chairman Brian Coleman and Tory mayoral candidate Shaun Bailey, who grew up near Grenfell, had previously called for her to quit. But the Fire Brigades Union said it was wrong to “scapegoat” firefighters.
Mr Khan’s decision was also influenced by the imminent publication of a damning report into the brigade’s management by Her Majesty’s Inspectorate. There is concern that it is failing to respond quickly enough to major flaws identified by the inquiry.
In a statement today, Ms Cotton, London’s first female fire commissioner, said she was “proud to have stood shoulder to shoulder” with firefighters.
She said: “I will never forget tragedies like the Clapham Junction rail disaster or the acts of terrorism that we have faced, but Grenfell Tower was without doubt the worst fire we had ever experienced.
“The brigade has and will keep making the changes it can make and continue its fight for all of the other changes that are needed, to prevent such a terrible incident and loss of life from happening again.”
Mr Khan thanked her for her service, hailed her as a role model for women entering the fire brigade and wished her “all the best in her retirement”.
He said: “I will be appointing a new fire commissioner shortly and it’s right that they can quickly take on the responsibility to drive forward the changes being made within the brigade, and to deliver on the recommendations made in the Grenfell Tower inquiry report.”
His intervention was sparked when the Grenfell Next Of Kin group, claiming to be the “voice of London”, went to City Hall to demand Ms Cotton’s resignation.
Ms Cotton was also damaged when Grenfell inquiry chairman Sir Martin Moore-Bick said the brigade’s planning and preparation for a fire such as at Grenfell was “gravely inadequate” and that it failed to learn the lessons of the 2009 fatal tower block fire at Lakanal House in Camberwell.
He said it was likely there would have been “fewer fatalities” if Grenfell had been evacuated between 1.30am and 1.50am, and blamed brigade commanders on the scene for sticking with the “stay put” advice to trapped residents.
The strategy was rescinded at 2.47am. The claim that more lives could have been saved by an evacuation was strongly disputed by the FBU.
After the inquiry’s first report was published in October, Ms Cotton changed her position to say that the brigade would have “responded differently” had it known what it does now. She was on the scene at Grenfell but not in operational command.