The Supreme Court has dismissed the government's appeal in a landmark case about Brexit, meaning Parliament will be required to give its approval before official talks on leaving the EU can begin.

The ruling is a significant, although not totally unexpected, setback for Theresa May.

What will the prime minister do next and what impact will the ruling have on the process of leaving the EU, following last year's referendum vote?

Why did the court say Parliament should trigger Article 50?

The highest court in the UK dismissed the government's argument that it has the power to begin official Brexit negotiations with the rest of the EU without Parliament's prior agreement.

By a margin of eight to three, the 11 justices upheld November's High Court ruling which stated that it would be unlawful for the government to rely on executive powers known as the royal prerogative to implement the outcome of last year's referendum.

It said a law would have to be passed to authorise Article 50 but the precise form such legislation should take was "entirely a matter" for Parliament.

What happens next?

Image copyright PA

Attorney General Jeremy Wright said the government would "comply with the judgement of the court and do all that is necessary to implement it".

In a statement to Parliament setting out details of the government's legislative response, David Davis said he intended to publish an outline bill "within days".

The BBC's political editor Laura Kuenssberg said the details could be announced as early as Thursday, with a view to staging the first vote next week and getting it through the Commons within a couple of weeks.

So Parliament's voice will be heard - but how?

Image copyright PA

We will get more details from the government later this week, with draft legislation already said to have been prepared in preparation for the appeal being rejected.

The new bill is expected to be short, with the government's lawyer suggesting during the hearing that "one-line" legislation could be put forward.

Both the House of Commons and House of Lords will have to vote in favour of it.

Separately, the government has agreed to produce an official policy document known as a White Paper explaining its objectives for the upcoming Brexit negotiations.

Ministers initially resisted the move, saying it would take too long, but Theresa May has agreed to it. The concession is being seen as a victory for opposition parties and a group of former Tory ministers who oppose a so-called "hard Brexit" and want to examine the government's plans in greater detail.

How long will this process take?

Image copyright PA

The bill will be given special priority by Parliament, whose order of business is still largely controlled by ministers.

While Tory MPs would like to see it fast-tracked through Parliament, many Labour, Lib Dem and SNP MPs will want as much time as possible to discuss a variety of issues and to make amendments.

The SNP responded to the ruling by saying it would table 50 "serious and substantive" amendments.

Labour said it too would seek to amend the bill but would not "frustrate" the Brexit process.

However it pans out, BBC Parliamentary correspondent Mark D'Arcy says the bill could pass through the Commons before the half-term recess in the middle of February, giving ample time for the Lords to then consider it and for it to become law before the end of March.

While there are some MPs who want the process to be delayed, they are vastly outnumbered by those who want the government to get on with it so that the UK will have left the EU by the time of the next election - scheduled for May 2020.

Is there any chance of Brexit being blocked?

Image copyright PA

In theory, yes there is. But in reality it is extremely unlikely to happen.

Few, if any, Conservative MPs are likely to vote against Article 50. In fact, only one - the europhile former chancellor Ken Clarke - has said he will do so.

Given that the Tories have a working majority of 15 in the Commons, this means that the bill is guaranteed to pass - especially since a majority of Labour MPs have said they will not stand in the way of the process and many will actually vote for Article 50.

Although the Lib Dems, the SNP and some Labour MPs are likely to vote against, this will make little difference. What will be more interesting is if a coalition of pro-European Conservatives and opposition MPs join forces to win concessions, over the extent of Parliamentary scrutiny of the two-year process.

Events in the Lords - where the government does not have a working majority and there are 178 non-affiliated cross-bench peers - could be more unpredictable. Mark D'Arcy says there are murmurings of an organised attempt to resist Article 50 and a "doomed last stand" by diehard Remainers.

But amid warnings that any attempt to block Brexit could trigger a general election, in which the future of the Lords would be a major issue - it is likely that the skirmishes will amount to just that and the government will eventually get its way.

What does it mean for Scotland, Northern Ireland and Wales?

Image copyright AFP

The Supreme Court case wasn't just a battle over the powers of the executive and the legislature.

The justices heard a number of separate but related challenges to the government's Brexit approach, centred around the involvement of the devolved administrations in Scotland, Wales and Northern Ireland.

But the court unanimously ruled that devolved administrations did not need to be consulted, and did not have a right to veto Article 50.

The government has previously said Scotland, Wales and Northern Ireland will be kept fully involved.