In his resignation letter - published in the middle of Labour's party conference in Brighton - the MP said his party leader had made Labour "more divided than ever".
Mr McDonald also accused him of not honouring his pledges to members.
Sir Keir thanked him for his service but said his own focus was on "winning the next general election".
But former shadow chancellor John McDonnell, a leading figure on Labour's left, said: "Questions have got to be asked about Keir Starmer… the conference is falling apart."
Mr McDonald previously served as shadow transport secretary on Jeremy Corbyn's front bench, but he became one of the few members to survive the handover of power to Sir Keir, and stayed in the top team as shadow secretary for employment rights and protections.
In recent months, his focus had been on creating Labour's new programme of employment rights, which was unveiled at the conference on Saturday by deputy leader Angela Rayner.
Mr McDonald said he had accepted the job "because I wanted to fight for the working people of this country", but had quit over a lack of support from his leader over bringing in a £15-an-hour minimum wage.
Sources close to Sir Keir told the BBC they were not unhappy at the departure, insisting this week was "all about change and closing the door on the Corbyn era".
The Labour leader's team sought to play down tensions over the minimum wage issue, with party sources telling the BBC they would be relaxed if members supported a rise.
Labour MP Barry Gardiner - who served alongside Mr McDonald in Mr Corbyn's shadow cabinet - told the BBC he was "extremely shocked" to hear of the resignation, saying he had been "a very powerful voice for workers in the country".
But the founder of left-wing Labour activist group Momentum, Jon Lansman, joined Mr McDonald's criticism of Sir Keir, telling BBC News: "He promised to unite the party and actually, unfortunately, he's driving wedges within the party."
Fellow members of Sir Keir's top team expressed shock at the resignation.
Shadow foreign secretary Lisa Nandy said: "It's a shame. I'm sure he'll focus on working for the party from the back benches."
Shadow work and pensions secretary Jonathan Reynolds said Mr McDonald was "a friend of mine" and he was "sad to see him go".
But he disagreed with the remarks about division in the party, adding: "We have seen this conference, frankly, Labour facing towards the general election in a way that is not just ambitious in terms of the pledges… but we have also tried to do that in a gain that gains credibility that is required to win power".
As news of the resignation broke in the conference hall, one delegate shouted "Andy McDonald, solidarity!" to loud cheers from some in the crowd.
The reaction of sources close to the Labour leadership to Andy McDonald's resignation can best be described as "close the door on your way out".
But they clearly want to turn adversity to advantage.
Having pushed through leadership rule changes which infuriated the left, they insist that this week is all about change and showing Labour is a potential party of government.
So the departure of a survivor of the Jeremy Corbyn era is seen to play into that narrative. One source described him as "the last Corbynista standing".
Some are suggesting it was part of a co-ordinated attempt to undermine Sir Keir's leadership.
Mr McDonald's resignation letter says Sir Keir's pledges to the membership were not being honoured - raising directly an issue of trust.
His demand for a £15 minimum wage is supported by some unions who feel bruised by the Labour leadership's focus on changing party rules when they wanted the focus to be in members' living standards.
Mr McDonald insists he still wants to see Sir Keir in Downing Street - but he should "reflect" on his style of leadership and consult the party and the unions more.
In Mr McDonald's letter, the MP claimed his position was "untenable" after the leader's office instructed him go to a meeting at Labour's party conference and "argue against a national minimum wage of £15 an hour and against statutory sick pay at the living wage".
He said it was "something I could not do", adding: "After many months of a pandemic when we made commitments to stand by key workers, I cannot now look those same workers in the eye and tell them they are not worth a wage that is enough to live on, or that they don't deserve security when they are ill.
Mr McDonald said it was a "bitter blow" that Labour had not followed the country in its "renewed awareness of how important the work done by millions of low-paid workers truly is".
He added: "I joined your frontbench team on the basis of the pledges that you made in the leadership campaign to bring about unity within the party and maintain our commitment to socialist policies.
"After 18 months of your leadership, our movement is more divided than ever and the pledges that you made to the membership."
Responding to the letter, Sir Keir released a statement which said: "I want to thank Andy for his service in the shadow cabinet.
"Labour's comprehensive New Deal for Working People shows the scale of our ambition and where our priorities lie.
"My focus and that of the whole party is on winning the next general election so we can deliver for working people who need a Labour government."