After new files revealed the depth of the Labour veteran's relationship with the late sex offender, Starmer is facing what is widely seen as the gravest crisis of his 18 months in power over his decision to send Mandelson to Washington DC in December 2024.
The loss of McSweeney, 48, a strategist who was instrumental in Starmer's rise to power, is the latest in a series of setbacks, less than two years after the Labour Party won one of the largest parliamentary majorities in the United Kingdom's modern history.
McSweeney said in a statement that he had been closely involved in the appointment of Mandelson.
"The decision to appoint Peter Mandelson was wrong. He has damaged our party, our country and trust in politics itself," McSweeney said in a statement posted on X by political correspondents.
"When asked, I advised the Prime Minister to make that appointment and I take full responsibility for that advice."
Starmer had fired Mandelson in September from his ambassadorial job over earlier revelations about his Epstein ties.
But critics say the emails recently published by the US Justice Department have brought serious concerns about Starmer's judgment to the fore.
They argue that he should have known better than to appoint Mandelson in the first place.
Documents published as part of a huge trove of Epstein files made public in the United States suggested Mandelson sent market-sensitive information to the convicted sex offender when he was the UK government's business secretary during the 2008 financial crisis.
Starmer's government has promised to release its own emails and other documentation related to Mandelson's appointment, which it says will show that Mandelson misled officials.
Mandelson, a former cabinet minister, ambassador and elder statesman of the governing Labour Party, has not been arrested or charged.
The leader of the opposition Conservatives Kemi Badenoch said the resignation was overdue and that "Keir Starmer has to take responsibility for his own terrible decisions".
Nigel Farage, head of the populist Reform UK party, which is leading in the polls, said he believed Starmer's time would soon be up.
Starmer has spent the last week defending McSweeney, a strategy that could prompt further questions about his own judgment.
In a statement on Sunday, Starmer said it had been "an honour" working with him.
"Our party and I owe him a debt of gratitude, and I thank him for his service," he said, praising McSweeney's role in helping the Labour party win the 2024 election.
Many Labour MPs had blamed McSweeney for the appointment of Mandelson and the damage caused by the publication of the exchanges between Epstein and Mandelson.
Others have said Starmer must go.
One Labour MP, speaking on condition of anonymity, said McSweeney's resignation had come too late: "It buys the PM time, but it's still the end of days."
It was unclear who would replace McSweeney.
Vidhya Alakeson, who worked closely with Starmer in opposition, is the prime minister's deputy chief of staff.
with PA and PA