The decision is a complication for Prime Minister Theresa May, who wanted to trigger Article 50 of the Lisbon Treaty
-- the legal mechanism that begins the process of leaving the EU -- by the end of March. Doing so would open the door for EU negotiations, which are likely to last two years.
May had promised lawmakers a vote on the outcome of the talks, but wanted to begin the process without a decision in parliament.
The Supreme Court judges voted eight to three against the government, upholding a November High Court decision. The judges, who deliberated the case over four days in December, said that the legal consequences of leaving the EU were great enough to require an act of parliament to start the process.
"To proceed otherwise would be a breach of settled constitutional principles stretching back many centuries," Lord David Neuberger, president of the Supreme Court, said as he read out the ruling.
But the court decided that the UK government did not need the approval of devolved governments in Scotland, Northern Ireland and Wales to begin the negotiating process.
That decision is likely to be met with relief at 10 Downing Street, as 62% of Scots voted to remain in the EU in last June's referendum.
What the UK government said
The government said it was disappointed by the ruling, but would abide by it.
Jeremy Wright, the Attorney General for England and Wales, told reporters outside the court that ministers would "comply with the judgment of the court and do everything necessary to implement it."
But a spokesperson for Theresa May said the ruling would not change the government's Brexit timeline.
"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," the spokesperson said in a statement.
"It's important to remember that parliament backed the referendum by a margin of six to one and has already indicated its support for getting on with the process of exit to the timetable we have set out."
Brexit has become a key test of Prime Minister May's leadership. May took over the premiership after former leader David Cameron stood down over the Brexit vote. Cameron had called the referendum but had campaigned for the country to remain in the union.
What happens next
The government must now introduce legislation to the House of Commons, which could delay May's plan to trigger Article 50 by the end of March.
David Davis, the Brexit Secretary, said legislation would be introduced "within days" and would be the "most straightforward possible".
The opposition Liberal Democrat Party and Scottish National Party (SNP) are opposed to Brexit, and are likely to put up the hardest fight. The SNP said on Tuesday that it would table 50 "serious and substantive" amendments to the government's bill.
Tim Farron, the leader of the Liberal Democrats, said the party would vote against the triggering of Article 50 unless the government promised a referendum on the terms of the final exit deal with the EU.
Jeremy Corbyn, leader of the Labour Party, the biggest opposition group in the House of Commons, said on Twitter 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."
But Labour has made it clear that it would not ultimately stand in May's way, meaning the government is likely to win the eventual vote on Article 50.
Will Brexit lead to the breakup of Britain?
In their ruling, the Supreme Court judges rejected an argument that devolved administrations in Scotland, Wales and Northern Ireland had the right to be consulted on the Article 50 process. The assemblies were not entitled to a veto, the judges said.
The UK government has previously said they would have an input in other ways, but Sturgeon, the SNP leader, believes the UK government is not taking into account Scotland's views fully enough.
Sturgeon wants Scotland to remain part of the European single market, and she indicated on Tuesday that a new Scottish independence referendum could be on the cards if the UK does not accede to her demands.
"Is Scotland content for our future to be dictated by an increasingly right-wing Westminster government with just one MP here -- or is it better that we take our future into our own hands? It is becoming ever clearer that this is a choice that Scotland must make."
Reaction to the ruling
One of the claimants in the case, London-based businesswoman Gina Miller, welcomed the decision, saying Brexit had been "most divisive issue of a generation."
"Only parliament can grant rights to the British people and only parliament can take them away. No prime minister and no government can expect to be unanswerable or unchallenged. Parliament alone is sovereign," Miller said after the ruling.
She said she was "shocked by the levels of personal abuse that I have received from many quarters over the last seven months for simply bringing and asking a legitimate question."