Boris Johnson has said he will press on “undaunted” with his Brexit strategy despite MPs backing the principle of a further delay to the process.
The PM has vowed to introduce legislation needed to implement his agreement in Parliament next week.
But he will have to ask the EU for an extension beyond 31 October after MPs backed a motion designed to rule out a no-deal exit by 322 votes to 306.
The EU said it was up to the UK to “inform it of the next steps”.
The motion, which was tabled by Independent MP Sir Oliver Letwin, “withholds approval” for Boris Johnson’s Brexit deal until legislation implementing it has been passed.
It was due to be followed by a vote on the main government motion – whether or not to back the deal.
The motion – amended because of the vote on Sir Oliver’s amendment – was approved without MPs going into the division lobbies.
A vote on a cross-party amendment on preventing a no-deal referendum and holding a second referendum was also dropped.
The defeat is a serious setback for the PM, who has repeatedly insisted that the UK will leave at the end of the month come what may.