Mr Johnson suspended – or prorogued – Parliament for five weeks earlier this month, but judges said it was wrong to stop MPs carrying out duties in the run-up to Brexit on 31 October.
Supreme Court president Lady Hale said “the effect on the fundamentals of democracy was extreme.”
The PM says he “strongly disagrees” with the ruling but will “respect” it.
A raft of MPs have now called for the prime minister to resign and some have said they would attempt to force him out if he did not go of his accord.
Mr Johnson argued he wanted to carry out the prorogation so he could outline his government’s new policies in a Queen’s Speech.
But critics said he was trying to stop MPs from scrutinising his Brexit plans and the suspension was far longer than necessary.
At a speech in New York, the PM said he “refused to be deterred” on 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 from carrying out its duties “without reasonable justification”.
Delivering its conclusions, the Supreme Court’s president, Lady Hale, 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.
She added that it was important to emphasise the case was “not about when and on what terms” the UK left the EU, but about the decision to suspend Parliament.
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.
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: “I don’t think this was the right decision. 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.
Pushed on whether he would attempt to suspend Parliament again, he said there was “a good case for getting on with a Queen’s Speech anyway”, and the Supreme Court had not “remotely excluded” the possibility.
Labour leader Jeremy Corbyn said the ruling showed Mr Johnson’s “contempt for democracy”, adding: “I invite Boris Johnson, in the historic words, to consider his position.”
Mr Corbyn was due to close the Labour Party conference in Brighton with a speech on Wednesday, but has brought it forward to Tuesday afternoon so he can return to Parliament.
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”.
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?
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.
The leader of the Brexit Party, Nigel Farage, said the suspension was the “worst political decision ever” and called for Mr Johnson’s chief advisor to resign.
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.
What is the Supreme Court?
How did the government suspend Parliament?
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.