Boris Johnson's decision to suspend Parliament for five weeks was unlawful, the Supreme Court has ruled.
Judges said it was wrong to stop MPs carrying out duties in the run-up to the Brexit deadline on 31 October.
The PM, who has faced calls to resign, said he "profoundly disagreed" with the ruling but would "respect" it.
The Labour conference finished early following the ruling and MPs are returning to Westminster ready for Parliament to reconvene on Wednesday.
A senior government official said the prime minister spoke to the Queen after the Supreme Court ruling, but would not reveal the details of the conversation.
It comes after the court ruled it was impossible to conclude there had been any reason "let alone a good reason - to advise Her Majesty to prorogue Parliament for five weeks".
Mr Johnson, who returns to London from New York on Wednesday, also chaired a 30-minute phone call with his cabinet.
A source told the BBC that the Leader of the Commons Jacob Rees-Mogg said to other cabinet ministers on the call that the action by the court had amounted to a "constitutional coup".
The prime minister insisted he wanted to outline his government's policies in a Queen's Speech on 14 October, and to do that, Parliament must be prorogued and a new session started.
But critics said he was trying to stop MPs scrutinising his Brexit plans and the suspension was far longer than necessary.
During a speech in New York, the PM said he "refused to be deterred" from getting on with "an exciting and dynamic domestic agenda", and to do that he would need a Queen's Speech.
The court ruling does not prevent him from proroguing again in order to hold one, as long as it does not stop Parliament carrying out its duties "without reasonable justification".
A No 10 source said the Supreme Court had "made a serious mistake in extending its reach to these political matters", and had "made it clear that its reasons [were] connected to the Parliamentary disputes over, and timetable for" Brexit.
But Supreme Court president Lady Hale emphasised in the ruling that the case was "not about when and on what terms" the UK left the EU - it was about the decision to suspend Parliament.
Delivering the justices' conclusions, she said: "The decision to advise Her Majesty to prorogue Parliament was unlawful because it had the effect of frustrating or preventing the ability of Parliament to carry out its constitutional functions without reasonable justification."
Lady Hale said the unanimous decision of the 11 justices meant Parliament had effectively not been prorogued - the decision was null and of no effect.
Speaker of the Commons John Bercow said MPs needed to return "in light of the explicit judgement", and he had "instructed the House of Commons authorities to prepare... for the resumption of business" from 11:30 BST on Wednesday.
He said prime minister's questions would not go ahead, but there would be "full scope" for urgent questions, ministerial statements and applications for emergency debates.
Where does this leave Boris Johnson?
Short of the inscrutable Lady Hale, with the giant diamond spider on her lapel, declaring Boris Johnson to be Pinocchio, this judgement is just about as bad for the government as it gets.
Mr Johnson is, as is abundantly clear, prepared to run a general election campaign that pits Parliament against the people. And so what, according to that view of the world, if that includes the judges as part of the establishment standing in his way?
But there is a difference between being ruthless and reckless.
And the scope and strength of this judgement cannot just be dismissed as some pesky judges sticking their noses in.
Reacting to the ruling, Mr Johnson said it was an "unusual judgement", adding: "The prerogative of prorogation has been used for centuries without this kind of challenge.
"There are a lot of people who basically want to stop this country from coming out of the EU and we have a Parliament that is unable to be prorogued and doesn't want to have an election. I think it is time we took things forward."
The PM said getting a deal was "not made much easier with these sort of things in Parliament or the courts", but insisted the UK would still leave on 31 October.
Labour leader Jeremy Corbyn was due to close the Labour Party conference in Brighton with a speech on Wednesday, but brought it forward to Tuesday afternoon so he could return to Westminster.
He told cheering delegates: "Tomorrow Parliament will return. The government will be held to account for what it has done. Boris Johnson has been found to have misled the country. This unelected prime minister should now resign."
Lawyers for the government had argued the decision to prorogue was one for Parliament, not the courts.
But the justices disagreed, unanimously deciding it was "justiciable", and there was "no doubt that the courts have jurisdiction to decide upon the existence and limits of a prerogative power".
The court also criticised the length of the suspension, with Lady Hale saying it was "impossible for us to conclude, on the evidence which has been put before us, that there was any reason - let alone a good reason - to advise Her Majesty to prorogue Parliament for five weeks".
A spokesperson from the Attorney General's office said the government had acted in "good faith and in the belief that its approach was both lawful and constitutional".
"These are complex matters on which senior and distinguished lawyers have disagreed," a statement said.
"The Divisional Court led by the Lord Chief Justice agreed unanimously with the government's legal position, as did the Outer House in Scotland.
"We are disappointed that in the end the Supreme Court took a different view. We respect the judgment of the Supreme Court."
The damage is done
Wow! This is legal, constitutional and political dynamite.
It is worth just taking a breath and considering that a prime minister of the United Kingdom has been found by the highest court in the land to have acted unlawfully in shutting down the sovereign body in our constitution, Parliament, at a time of national crisis.
The court may have fallen short of saying Boris Johnson had an improper motive of stymieing or frustrating parliamentary scrutiny, but the damage is done, he has been found to have acted unlawfully and stopped Parliament from doing its job without any legal justification.
And the court has quashed both his advice to the Queen and the Order in Council which officially suspended parliament.
That means Parliament was never prorogued and so we assume that MPs are free to re-enter the Commons.
This is the most dramatic example yet of independent judges, through the mechanism of judicial review, stopping the government in its tracks because what it has done is unlawful.
Be you ever so mighty, the law is above you - even if you are the prime minister.
Unprecedented, extraordinary, ground breaking - it is difficult to overestimate the constitutional and political significance of today's ruling.
What was the court considering?
The ruling was made after a three-day hearing at the Supreme Court last week which dealt with two appeals - one from campaigner and businesswoman Gina Miller, the second from the government.
Mrs Miller was appealing against the English High Court's decision that the prorogation was "purely political" and not a matter for the courts.
The government was appealing against the ruling by Scotland's Court of Session that the prorogation was "unlawful" and had been used to "stymie" Parliament.
The court ruled in favour of Mrs Miller's appeal and against the government's.
How did those involved in the case react?
Speaking outside the court, Mrs Miller said the ruling "speaks volumes".
"This prime minister must open the doors of Parliament tomorrow. MPs must get back and be brave and bold in holding this unscrupulous government to account," she added.
The SNP's Joanna Cherry, who led the Scottish case, called for Mr Johnson to resign as a result of the ruling.
"The highest court in the United Kingdom has unanimously found that his advice to prorogue this Parliament, his advice given to Her Majesty the Queen, was unlawful," she said.
"His position is untenable and he should have the guts, for once, to do the decent thing and resign."
Former Prime Minister Sir John Major - one of the sponsors of the prorogation appeal - said it gave him "no pleasure to be pitted against a government and prime minister of my own party".
"No prime minister must ever treat the monarch or Parliament in this way again."
What about other politicians?
Mr Johnson was backed by US President Donald Trump at a joint press conference at the United Nations in New York.
"I'll tell you, I know him well, he's not going anywhere," said Mr Trump, after a US reporter quizzed the prime minister on whether he was going to resign.
But reaction at home was far more negative. Scotland's First Minister, the SNP's Nicola Sturgeon, said the ruling was the most significant constitutional judgement in her lifetime, and it would be "unthinkable" for Mr Johnson to remain in office.
Wales' First Minister, Labour's Mark Drakeford, said the court's decision had been a "victory for the rule of law" and the PM had "tried to play fast and loose with our constitution".
In Northern Ireland, the leader of the DUP, Arlene Foster, said the ruling must be respected, while Sinn Fein's vice president, Michelle O'Neill, said Mr Johnson should resign.
Other figures have taken to Twitter to support the court's decision, including former Tory minister Amber Rudd, who resigned her post - and the party whip - over the government's approach to Brexit.
Despite personal assurances from the PM, the Cabinet was not shown the legal advice around this prorogation.— Amber Rudd MP (@AmberRuddHR) September 24, 2019
This is an astonishing moment and I regret that the PM, who entered office with such goodwill, went down this route. I urge him to work with Parliament to pass a Deal.
The leader of The Brexit Party, Nigel Farage, said Mr Johnson must, "as a matter of honour", offer his resignation to MPs in Parliament on Wednesday.
The decision to prorogue Parliament had been a "disaster", he added, and there must be a general election "before very long because Parliament and the government have ceased to function".
Former Attorney General Dominic Grieve, who has been an outspoken critic of the suspension, said he was "not surprised" by the judgement because of the "gross misbehaviour by the prime minister".
He told the BBC's Victoria Derbyshire programme he was "delighted" the Supreme Court had "stopped this unconstitutional act in its tracks".
But Tory MP Andrew Bridgen said the court's decision was "the worst possible outcome for our democracy" and "an absolute disgrace".
He told the same programme: "What we've got is a Parliament that's completely out of step with sentiment of the country."
Fellow Tory MP and chairman of the pro-Brexit European Research Group Steve Baker said the ruling was an "earthquake moment".
He described the Commons as a "rotten Parliament" facing a "crisis", and called for a general election so a government with a majority could move forward.
What happened before Parliament was suspended?
Prorogation is a power that rests with the Queen, carried out by her on the advice of the prime minister.
And at the end of August - shortly before MPs returned from their summer recess - Mr Johnson called Her Majesty to advise she suspend Parliament between 9 September until 14 October.
MPs had been expecting to be in recess for some of these weeks for their party conferences.
But unlike prorogation, a recess must be agreed by a vote, and a number of MPs said they would have voted against it to ensure they could scrutinise Mr Johnson's Brexit plans.
The decision to prorogue prompted an uproar from the Commons, especially from MPs who had planned to take control of Parliament to force through a law to block a no-deal Brexit after Mr Johnson said the UK would leave the EU with or without a deal on the Halloween deadline.
Despite only sitting for a week, they did manage to pass that law ahead of prorogation and it received royal assent on 9 September.
What questions do you have about the Supreme Court's decision?
Use this form to ask your question:
If you are reading this page on the BBC News app, you will need to visit the mobile version of the BBC website to submit your question on this topic.