Media playback is unsupported on your device Media caption Boris Johnson reacts to losing key Brexit vote

Tory rebels and opposition MPs have defeated the government in the first stage of their attempt to pass a law designed to prevent a no-deal Brexit.

The Commons voted 328 to 301 to take control of the agenda, meaning they can bring forward a bill seeking to delay the UK's exit date.

In response, Boris Johnson said he would bring forward a motion for an early general election.

Jeremy Corbyn said the bill should be passed before an election was held.

In total, 21 Tory MPs, including a number of ex-cabinet ministers, joined opposition parties to defeat the government.

After the vote, Downing Street said those Tory MPs who rebelled would have the whip removed, effectively expelling them from the parliamentary party.

No 10 had hoped the threat of expulsion - and an election - would bring would-be rebels into line.

The longest-serving of the Tory rebels, ex-chancellor Ken Clarke, told BBC Newsnight he was still "a mainstream Conservative" but he didn't recognise his party any more.

The "knockabout character" of the prime minister had "the most right-wing cabinet a Conservative government has ever produced", he said.

Please upgrade your browser to view this interactive Did your MP vote in favour of allowing the government to suspend Parliament in order to secure Brexit on 30 October? Enter a postcode, or the name or constituency of your MP Seat vacant

The prime minister said the MPs' bill would "hand control" of Brexit negotiations to the EU and bring "more dither, more delay, more confusion".

He told MPs he had no choice but to press ahead with efforts to call an October election, adding: "The people of this country will have to choose."

The result means the MPs will be able to take control of Commons business on Wednesday.

That will give them the chance to introduce a cross-party bill which would force the prime minister to ask for Brexit to be delayed until 31 January, unless MPs approve a new deal, or vote in favour of a no-deal exit, by 19 October.

Media playback is unsupported on your device Media caption Corbyn: Get the bill passed first

The BBC understands the government intends to hold an election on 15 October, two days before a crucial EU summit in Brussels.

To call an election under the Fixed-term Parliaments Act, Mr Johnson would need support from Labour as he requires the backing of two-thirds of the UK's 650 MPs.

But Mr Corbyn said the legislation backed by opposition MPs and Tory rebels should pass before any election was held, to "take no deal off the table".

He added: "There is no majority to leave without a deal within the country".

Shadow justice secretary Richard Burgon said he did not trust Boris Johnson not to call an election for mid-October and then change the date afterwards.

He said the prime minister could "change the date so that during the general election campaign we crash out of the European Union with a no deal".

"We want it bolting down that a no-deal Brexit can't occur, and once that's done, we want a general election as soon as possible," he told the BBC.

The BBC's chief political correspondent, Vicki Young, said the government was framing the situation as the Labour leader trying to block Brexit, and that would be its argument going into a general election.

Could the Commons defeat be a benefit to PM?

It's hard to know where to start sometimes.

The pace and gravity of events in Westminster this week is both monumental and dizzying.

A prime minister has lost his wafer of a majority.

But some close to the prime minister believe that from this crisis comes an opportunity - to close the unfinished business of the referendum result in 2016, with the Tory party at last being the bearers of a crystal-clear message on Brexit.

It's a measure of how upside down the political norms are - that the prime minister losing his first vote in office is considered by some of his allies as a benefit.

Read more from Laura

SNP Westminster leader Ian Blackford said he was "delighted" that MPs had expressed a "very clear view" in favour of a law to block no deal.

"Boris Johnson and his government must respect the right of parliamentarians to represent the interests of their constituents," he said.

"Yes, there must be an election, but an election follows on from securing an extension to the [Brexit deadline]."