Gerry Adams has won his appeal to have two convictions for attempting to escape from prison in the 1970s overturned.
The Supreme Court said the former Sinn Féin president's convictions were quashed because Mr Adams' detention was unlawful.
He attempted to escape from the Maze Prison, also known as Long Kesh internment camp, in 1973 and 1974.
He was later sentenced to a total of four-and-a-half years in jail.
Mr Adams was in jail because he had been interned without trial, a practice that was introduced in Northern Ireland amid spiralling violence in the early 1970s.
More than 1,900 people suspected of being members of paramilitary organisations were detained, but many were arrested based on flawed intelligence.
Mr Adams has consistently denied being a member of the IRA.
The former Sinn Féin leader welcomed the Supreme Court's decision, saying internment without trial "set aside the normal principles of law and was based on a blunt and brutal piece of coercive legislation".
"There is an onus on the British government to identify and inform other internees whose internment may also have been unlawful," he said.
A clear record
Analysis by BBC News NI Home Affairs Correspondent Julian O'Neill
The highest court has set aside Gerry Adams' only convictions from Northern Ireland's Troubles.
Mr Adams, as well as repeatedly denying he was ever in the IRA, can now point to a clear record.
But it will not alter the historical narrative around him.
Imprisoning people without trial - internment - was a disastrous 1970s government policy.
Instead of controlling violence it inflamed it.
Now it has been found that arguably the most famous internee of all was put in jail unlawfully, due to an error.
At an earlier hearing in November, Mr Adams' lawyers argued his detention was unlawful because the interim custody order (ICO) used to detain him in July 1973 was not authorised by Willie Whitelaw, who was Northern Ireland secretary at the time.
Announcing the Supreme Court's judgement at a remote hearing on Wednesday, Lord Kerr - the former Lord Chief Justice of Northern Ireland - said the court had unanimously allowed Mr Adams' appeal and had quashed his convictions.
The judge said Mr Adams' detention was unlawful because it had not been "considered personally" by Mr Whitelaw.
He explained that Mr Adams, a former West Belfast MP, had been detained under an ICO made under the Detention of Terrorists (Northern Ireland) Order 1972 and that "such an order could be made where the secretary of state considered that an individual was involved in terrorism".
In the court's written judgment, Lord Kerr said the power to make such an order was "a momentous one", describing it as "a power to detain without trial and potentially for a limitless period".
"This provides an insight into Parliament's intention and that the intention was that such a crucial decision should be made by the secretary of state," he said.