Parliament has been sitting on a Saturday for the first time in 37 years to debate and vote on Boris Johnson's Brexit deal.
What just happened?
MPs have supported a motion tabled by Independent MP Sir Oliver Letwin that "withholds approval" for Boris Johnson's Brexit deal until legislation implementing it has been passed.
It was very close - the government lost by just 16 votes, by 322 to 306.
It was due to be followed by a vote on the main government motion - whether or not to back the deal. But the motion, as amended, was approved by MPs without a vote, as the government effectively accepted defeat.
A cross-party amendment on preventing a no-deal Brexit and holding a second referendum was not put to the vote either, after the government pulled the motion it was attached to.
What happens now?
Under the terms of the so-called Benn Act, the prime minister must send a letter to Brussels requesting a three-month Brexit delay by 2300 BST.
But Prime Minister Boris Johnson said: "I will not negotiate a delay with the EU and neither does the law compel me to do so."
He added: "I continue in the very strong belief that the best thing for the UK, and for the whole of Europe is for us to leave with this new deal on 31 October, and to anticipate the questions that are coming from the benches opposite, I will not negotiate a delay with the EU."
A Number 10 source said: "Parliament has voted to delay Brexit yet again.
"The prime minister will not ask for an extension - he will tell EU leaders there should be no delays, they should reject Parliament's letter asking for a delay, and we should get Brexit done on 31 October with our new deal so the country can move on."
The House of Commons Twitter account posted that the government now "must ask for an extension of Article 50 under the Benn Act and set out how it intends to proceed".
What have opposition parties said?
Labour leader Jeremy Corbyn told MPs: "Today is an historic day for parliament because it said it will not be blackmailed by a prime minister who is apparently prepared once again to defy a law passed by this parliament.
"I invite him to think very carefully about the remarks he just made about refusing, apparently, to apply for the extension which the EU number two Act requires him to do."
SNP justice and home affairs spokesperson Joanna Cherry tweeted: "So Boris Johnson loses again today but is threatening not to comply with BennAct or promises made to Scottish court.
"Just as well we are due back in court on Monday & Mr Speaker has just confirmed to me that he'll sign Extension letter if court so requires."
Is Boris Johnson's deal now dead?
No. The government plans to push ahead with the legislation enacting the treaty agreed by Boris Johnson in Brussels - the Withdrawal Agreement Bill on Monday.
They also want to hold another "meaningful vote" on the Brexit deal on Monday.
Commons Speaker John Bercow will not allow the government to ask the same question of MPs again - but he said he would give the matter consideration before giving a ruling on it on Monday.
What could happen in Parliament next week?
By BBC Parliamentary Correspondent Mark D'Arcy
If John Bercow allows the "meaningful vote", Labour MPs in pro-Brexit seats will be under massive pressure.
They would much rather go straight to a Withdrawal Agreement Bill, where they can tinker with the detail to their heart's content - possibly allying with dissident Tories to write a customs union into it.
And for the government, putting down a bill without the support of the DUP would be fraught with danger.
An early indicator will be whether the government can win the programme motion necessary to ensure the Bill gets through in quick time.