In the end it came down to the narrowest of margins. If just one of five Law Lords had voted differently, the people of the Chagos Islands would have been contemplating a return to their homeland in the Indian Ocean.
But for that one vote, the British government would have been facing a multi-million pound bill to enable the Chagossian exiles to go home and rebuild their lives.
The case, which went 3-2 in favour of the government, was argued with references dating as far back as the Magna Carta and Shakespeare's Richard II.
The core issue, however, was quite simple: "Was the British government acting lawfully when it declared in 2004 that nobody had the right of abode in the Chagos archipelago and that therefore anyone wanting to go there had to get an immigration permit?"
To put the question into proper context it is necessary to go back to the 1960s when the British government agreed that the US should take over the island of Diego Garcia as an air base.
The islanders, numbering about 2,000, were removed by the simple means of denying them any supplies.
The British government bought the company that employed them to harvest coconuts into fibre and lamp oil and then told them the business was closed.
The islanders were dumped in Mauritius and an Immigration Order preventing anyone from going back was issued in 1971.
As Lord Hoffmann, one of the judges who has now finally ruled against the Chagossians, remarked in his judgment: "Into [their] innocent world there intruded, in the 1960s, the brutal realities of global politics."
It was only later compensation was paid - first £695,000 in 1973 and then, after protests, another £4m in 1982. British citizenship was also given to many in 2002.
Regardless, the islanders continued to protest and the British courts began to side with them.
In 2000 a court held that the Immigration Order was unlawful and it was said of the commissioner who issued it that he was supposed to govern, not remove the people.
It withdrew the 1971 order and in fact allowed islanders the right of return, but nobody could exercise it because there was nothing to go back to.
The then foreign secretary Robin Cook was embarrassed and set up a feasibility study to see if the people could return to some of the outer islands. Diego Garcia was out of bounds because of the US air base.
But the report, published in 2002, was sceptical any long-term settlement could be established.
Then in 2004 the government made a new order that nobody had a right to live in the British Indian Ocean Territory, and citing fears of terrorism in the post 9/11 world, it said a permit would be needed to go there.
To get round the problem of the 1971 order not being legal, the government acted by royal prerogative, the residual executive power exercised by a government through the Crown.
The new order was then declared unlawful by a divisional court, which described it as "irrational" because it did not take the interests of the islanders into account.
This was supported by the Appeals Court, which said that Mr Cook had created a "legitimate expectation" of a return that had not been satisfied.
And so the case went up the House of Lords Appeal Committee for a final ruling.
The islanders argued on two points.
The government replied by saying that the royal prerogative was "primary law" and could not be challenged by the courts.
The majority opinion in the House of Lords, expressed in the opinion of Lord Hoffman, held that while the royal prerogative could be challenged in court, in this case, the government was right.
"The right of abode is a creature of the law. The law gives it and the law may take it away," he ruled.
As for the issue of "good governance", he rejected the argument that this meant the interest of the islanders alone had to be considered.
Lord Hoffman said there were wider interests, and wrote: "Her Majesty in Council is therefore entitled to legislate for a colony in the interests of the United Kingdom."
He also said the government was entitled to take into account the interest of its ally, the United States.
Lord Hoffmann was joined by two of the four other justices.
The minority opinion, as written by Lord Bingham, echoed some of the scathing criticism of the government in the lower courts.
Dismissing the government's security concerns about letting islanders return, he wrote that despite "highly imaginative letters written by American officials, it was not said that the criminal conspiracy headed by Osama bin Laden was, or was planning to be, active in the middle of the Indian Ocean".
Lord Bingham said the royal prerogative did not entitle the government to "exile an indigenous population from its homeland".
And he held that Robin Cook had indeed created an expectation the islanders might return: "[They] were clearly intended to think, and did, that for the foreseeable future their right to return was assured. The government could not lawfully resile from its representation without compelling reason, which was not shown."
Lord Mance, who supported Lord Bingham in the minority opinion, quoted Shakespeare to the government on the miseries of exile.
Richard II, he recalled, had exercised the then power of the king to impose such a sentence on the Duke of Norfolk, who replied: "A heavy sentence, my most sovereign liege, And all unlook'd for from your Highness' mouth."