MPs have backed a bid to stop a new prime minister suspending Parliament to force through a no-deal Brexit.
A majority of 41 approved an amendment that blocks suspension between 9 October and 18 December unless a Northern Ireland executive is formed.
Four cabinet ministers abstained and 17 Conservative MPs rebelled against the whip, including minister Margot James, who has resigned.
Leadership contender Boris Johnson has not ruled out suspending Parliament.
His rival Jeremy Hunt has ruled out this move.
The four cabinet ministers who abstained are International Development Secretary Rory Stewart, Business Secretary Greg Clark, Chancellor Philip Hammond and Justice Secretary David Gauke.
A Downing Street spokesman said the prime minister was “obviously disappointed that a number of ministers failed to vote in this afternoon’s division”.
“No doubt her successor will take this into account when forming their government,” the spokesman said.
BBC political editor Laura Kuenssberg said the Commons had now made it harder for a new prime minister to suspend Parliament.
If the 31 October deadline is reached without Parliament backing an agreement between the UK government and the EU, the UK is scheduled to leave the EU without a deal.
MPs have consistently voted against a no-deal Brexit, but the prime minister could try to get around that by suspending Parliament – proroguing – in the run-up to the deadline, denying them an opportunity to block it.
The amendment to the Northern Ireland (Executive Formation) Bill was put forward by MPs including former minister Alistair Burt and Brexit committee chairman and Labour MP Hilary Benn.
It would mean that if Parliament is prorogued when the government publishes reports on the situation in Northern Ireland, MPs must be recalled to debate them.
Mr Burt told the BBC that Parliament had said “very clearly please don’t bypass us… Parliament must be sitting in the run up to 31 October”.
Mr Benn said: “This is a very significant amendment because it sends a very significant message to the prime minister – if you think you can lock the doors on that chamber and tell us to go away until the 31st October, Parliament will not allow that to happen.”
When asked about suspending Parliament during his leadership campaign, Mr Johnson said he would “not take anything off the table”.
He said he wanted to leave the EU on 31 October “come what may”.
MPs also rejected a government attempt to disagree with an amendment put forward by a group of peers, which also bids to stop Parliament being suspended to force through a no-deal Brexit, by 315 votes to 273, a majority of 42.
The bill will now return to the Lords for consideration.
Analysis from constitutional expert Professor Meg Russell
Professor Russell says the votes represent “quite a heavy defeat” for the government, putting “practical obstacles” in the way of ministers seeking to close down – or prorogue – Parliament.
“On one level prorogation is absolutely normal – it is not a dirty word,” she says.
“But what is unusual is the idea of proroguing Parliament for a political reason – that is a very, very problematic idea.
“Using prorogation as a political tool risks bringing the monarch into politics, as she needs to give her consent to close down Parliament.
“That would put the Queen in a very difficult situation.”
Earlier in the Commons, former education secretary Justine Greening told MPs: “What have we come to in Britain when we have to have amendments to ensure Parliament can still operate?
“Firstly you don’t win a debate by closing down the main chamber in which the country’s people’s views are aired and you don’t unite a country by muzzling the representatives of people around those communities.”
She said it was “entirely untenable” and “actually quite dangerous to shutdown Parliament as a time of such uncertainty”.
But DUP Westminster leader Nigel Dodds said it was “very disconcerting” to see a bill about Northern Ireland “hijacked for other purposes and particularly to see the debates taking place not even on the issues that directly affect Northern Ireland”, like marriage and abortion.
And Northern Ireland Minister John Penrose said the amendments attempting to block no deal were “pretending to be democratic but trying to prevent the democratic referendum decision from ever happening at all”.
Former Tory prime minister John Major has said he will seek a judicial review if the next prime minister tries to suspend Parliament.
Campaigner Gina Miller has threatened the same action.