Senior Labour MP Emily Thornberry has resigned from Ed Miliband’s shadow cabinet after being accused of snobbery when she tweeted a picture of a house decked out in St George’s flags.

The shadow attorney general, who represents Islington South and Finsbury, initially defended posting the picture, which she took while out campaigning in the Rochester and Strood byelection. She later posted a message apologising if she had caused offence.

However, hours later, she stepped down from her role in Labour’s top team, after party sources made clear that Miliband was furious about the tweet.

The row is set to create a media furore the day after the Rochester byelection, which is likely to show Nigel Farage’s populist insurgents Ukip triumph over the Conservatives and the other established political parties.

Thornberry’s publication of the picture, which showed a semi-detached house draped in flags with a white van parked outside, was criticised by her political rivals but also by some within her party.

Emily Thornberry’s tweet Photograph: Twitter

Simon Danczuk, Labour MP for Rochdale, suggested it was “derogatory and dismissive of the people”. He told the Mail Online it was “like the Labour party has been hijacked by the north London liberal elite, and it’s comments like that which reinforce that view”.

On Twitter, the Ukip leader Nigel Farage said Thornberry had “let Miliband’s mask slip” and questioned what she was trying to imply about the area by tweeting the picture.

After the first barrage of complaints, Thornberry said her critics may have been showing “a somewhat prejudiced attitude towards Islington”. She added: “I’ve been down in Rochester … and I’ve been tweeting one or two quotes of what people have said to me on the doorstep, and images that I’ve seen … and then I came across a house that was covered absolutely from the roof all the way down to the ground with England flags – they couldn’t even see out of the window. It was an amazing image, so I took a photograph of it and I put it on Twitter.”

The Labour MP said she thought there was “a lot of mischief-making” going on. “You know, I think the truth is, while the byelection’s going on, people haven’t got a lot to say,” she said. “They can say there’s people out on doorsteps knocking on doors. And I suspect that those kind of people are trying to promote a somewhat prejudiced attitude towards Islington.

“I was brought up on a council estate and I’ve never seen a house where people can’t see out of the window because of England flags. It was just trying to give, to the people who follow me on Twitter, a kind of picture of what the Rochester byelection is like.”

She subsequently tweeted an apology, after receiving a dressing-down from Miliband, for “any offence caused” saying: “People should fly the England flag with pride!” A Labour source said: “It is fair to say that he made his view very clear that people should fly the England flag with pride.”

Just after the polls had closed in Rochester at 10pm, it emerged Thornberry had resigned. In a statement released by the party, Thornberry said: “Earlier today I sent a tweet which has caused offence to some people. That was never my intention and I have apologised. However, I will not let anything distract from Labour’s chance to win the coming general election.

“I have therefore tonight told Ed Miliband I will resign from the shadow cabinet.”