Parliament must vote on whether the government can start the Brexit process, the Supreme Court has ruled.
The judgement means Theresa May cannot begin talks with the EU until MPs and peers give their backing - although this is expected to happen in time for the government's 31 March deadline.
But the court ruled the Scottish Parliament and Welsh and Northern Ireland assemblies did not need a say.
Brexit Secretary David Davis promised a parliamentary bill "within days".
Sources have told the BBC the bill - to trigger Article 50 of the Lisbon Treaty and get formal exit negotiations with the EU under way - will be introduced this Thursday, with an expectation that it could pass through the House of Commons in a fortnight.
What the Supreme Court case was about
During the Supreme Court hearing, campaigners argued that denying the UK Parliament a vote was undemocratic and a breach of long-standing constitutional principles.
They said triggering Article 50 would mean overturning existing UK law, so MPs and peers should decide.
But the government argued that, under the Royal Prerogative (powers handed to ministers by the Crown), it could make this move without the need to consult Parliament.
And it said that MPs had voted overwhelmingly to put the issue in the hands of the British people when they backed the calling of last June's referendum in which UK voters backed Brexit by 51.9% to 48.1%.
What the court said
Reading out the judgement, Supreme Court President Lord Neuberger said: "By a majority of eight to three, the Supreme Court today rules that the government cannot trigger Article 50 without an act of Parliament authorising it to do so."
He added: "Withdrawal effects a fundamental change by cutting off the source of EU law, as well as changing legal rights.
"The UK's constitutional arrangements require such changes to be clearly authorised by Parliament."
The court also rejected, unanimously, arguments that the Scottish Parliament, Welsh Assembly and Northern Ireland Assembly should get to vote on Article 50 before it is triggered.
Lord Neuberger said: "Relations with the EU are a matter for the UK government."
Government reaction: This will not delay Brexit
Outlining plans to bring in a "straightforward" parliamentary bill on Article 50, Mr Davis told MPs he was "determined" Brexit would go ahead as voted for in last June's EU membership referendum.
He added: "It's not about whether the UK should leave the European Union. That decision has already been made by people in the United Kingdom."
"There can be no turning back," he said. "The point of no return was passed on 23 June last year."
Outside the Supreme Court, Attorney General Jeremy Wright said the government was "disappointed" but would "comply" and do "all that is necessary" to implement the court's judgement.
A Downing Street spokesman said: "The British people voted to leave the EU, and the government will deliver on their verdict - triggering Article 50, as planned, by the end of March. Today's ruling does nothing to change that."
Foreign Secretary Boris Johnson, a leading Leave campaigner, tweeted: "Supreme Court has spoken. Now Parliament must deliver will of the people - we will trigger A50 by end of March. Forward we go!"
Campaigner Gina Miller gives her reaction
Investment manager Gina Miller, one of the campaigners who brought the case against the government, said Brexit was "the most divisive issue of a generation", but added that her victory was "not about politics, but process".
"I sincerely hope that going forward that people who stand in positions of power and profile are much quicker in condemning those who cross the lines of common decency and mutual respect," she also said.
Her co-campaigner, hairdresser Deir Tozetti Dos Santos, said: "The court has decided that the rights attaching to our membership of the European Union were given by Parliament and can only be taken away by Parliament.
"This is a victory for democracy and the rule of law. We should all welcome it."
BBC Political Editor Laura Kuenssberg's view
"The sighs of relief are real in Whitehall this morning for two reasons.
"The justices held back from insisting that the devolved administrations would have a vote or a say on the process. That was, as described by a member of Team May, the 'nightmare scenario'.
"And second, the Supreme Court also held back from telling the government explicitly what it has to do next. The judgement is clear that it was not for the courts but for politicians to decide how to proceed next.
"That means, possibly as early as tomorrow, ministers will put forward what is expected to be an extremely short piece of legislation in the hope of getting MPs to approve it, perhaps within a fortnight." Read Laura's blog in full.
What Tory MPs and opposition parties say
Labour leader Jeremy Corbyn said: "Labour respects the result of the referendum and the will of the British people and will not frustrate the process for invoking Article 50."
But he added that his party would "seek to amend the Article 50 Bill to prevent the Conservatives using Brexit to turn Britain into a bargain basement tax haven off the coast of Europe".
However, UKIP leader Paul Nuttall warned MPs and peers not to hamper the passage of the legislation.
"The will of the people will be heard, and woe betide those politicians or parties that attempt to block, delay, or in any other way subvert that will," he said.
The Scottish National Party said it would put forward 50 "serious and substantive" amendments to the government's parliamentary bill for triggering Article 50.
Among them, it wants Mrs May to set out her negotiating aims in an official document known as a white paper and to consult the Scottish government and other devolved administrations through the UK-wide joint ministerial committee.
Several Conservative MPs, including former ministers Alistair Burt, Nicky Morgan and Anna Soubry, also want a white paper, but former party leader Iain Duncan Smith predicted any bill would be "very tight", offering little scope for amendments.
Liberal Democrat leader Tim Farron said his MPs and peers would vote against Article 50 unless there was guarantee of the public having a vote on the final deal reached between the UK and EU.
Supreme Court ruling - key points
- The 1972 Act that took the UK into the then EEC creates a process by which EU law becomes a source of UK law
- So long as that act remains in force, it means that EU law is an "independent and overriding source" of the UK's legal system
- Unless Parliament decides otherwise, this remains the case
- Withdrawal from the EU makes a fundamental change to the UK's constitutional arrangements because it will cut off the source of EU law
- Such a fundamental change will be the inevitable effect of a notice being served
- The UK constitution requires such changes can only be made by Parliament
- The fact that withdrawal from the EU would remove some existing domestic rights of UK residents also renders it impermissible for the government to withdraw from the EU Treaties without prior parliamentary authority
Analysis by Dominic Casciani, BBC home affairs correspondent
"This momentous judgement is about one thing alone: the rule of law and how the UK, as a champion of that steady, calm form of government, gets on with the business of leaving the EU.
"But what it also makes clear is that membership of the EU is messy in constitutional terms - so only Parliament has the right to pull us out. It can't be done by the stroke of a minister's pen.
"On the devolution side, the government did however win hands down. The court unanimously ruled that the devolved bodies have no real say in leaving the EU: constitutional power - the means to change the fabric of the United Kingdom, rests with the UK Parliament alone."
Supreme Court split
The Supreme Court's judgement backs that made by the High Court last year, against which the government appealed.
Those who rejected the government's argument were: Lord Neuberger, Lady Hale, Lord Mance, Lord Kerr, Lord Clarke, Lord Wilson, Lord Sumption and Lord Hodge
Those who decided in favour of it were: Lord Carnwath, Lord Hughes and Lord Reed.
Supreme Court on Northern Ireland and Brexit
During the four-day Supreme Court hearing in December, the justices heard arguments that Northern Ireland had a unique place in the UK constitution because of the nature of the 1998 Belfast Agreement and the devolved bodies that flowed from it.
Counsel argued that Northern Ireland's constitution could not be changed without a vote by its people.
But in its judgement, the Supreme Court unanimously ruled that not only did the devolved bodies have no role in deciding the future of the UK as a whole in the EU, Northern Ireland had no special status beyond this either.
They ruled that, while Northern Ireland's people did indeed have a fundamental constitutional say on being part of the UK, that did not extend to being part of the EU.