The law which has allowed people to be convicted of murder even if they did not inflict the fatal blow has been wrongly interpreted for more than 30 years, the Supreme Court has ruled.
The joint enterprise law has been used to convict people in gang-related cases if defendants "could" have foreseen violent acts by their associates.
However, judges ruled it was wrong to treat "foresight" as a sufficient test.
Their decision could pave the way for hundreds of prisoners to seek appeals.
It will apply in England, Wales, Northern Ireland and most UK overseas common law territories but not in Scotland, which has its own rules on joint enterprise.
Campaigners against joint enterprise welcomed the ruling, saying it would mean a fairer law - but some murder victims' relatives said they were worried about possible appeals.
Ameen Jogee (L) and Mohammed Hirsi were both given life sentences under a joint enterprise conviction
The ruling came after a panel of five Supreme Court judges considered the case of Ameen Jogee, who had been convicted under joint enterprise of the murder of former Leicestershire police officer Paul Fyfe in 2011.
The court heard that Jogee had "egged on" his friend Mohammed Hirsi, who stabbed Mr Fyfe in the heart. Both men received life sentences for murder.
Jogee had argued he was not inside the house when the incident took place, and could not have foreseen what his friend intended to do.
Gary Dobson and David Norris were convicted under joint enterprise of the 1993 murder of Stephen Lawrence
Joint enterprise law has been used to convict and hand down long sentences in several high-profile cases:
Delivering the judgement, Lord Neuberger said it was wrong to treat "foresight" as a sufficient test to convict someone of murder.
"The court is satisfied after a much fuller review of the law than in the earlier cases that the courts took a wrong turn in 1984. And it is the responsibility of this court to put the law right," he said.
The judgement refers to a ruling by the Judicial Committee of the Privy Council in a case in which three gang members armed with knives burst into the home of a prostitute and her husband in Hong Kong, intending to collect a debt.
The husband was stabbed to death at the hand of at least one of the gang members. All three were convicted of murder.
BBC legal affairs correspondent Clive Coleman said Thursday's ruling did not mean those convicted under joint enterprise would automatically be able to appeal.
The change to the law is not retrospective - so anyone appealing would have to show that they would suffer "substantial injustice" if they were not allowed to appeal, our correspondent said.
In Jogee's case, the Supreme Court "set aside" his conviction - meaning the verdict in his original trial no longer stands.
However, the ruling does not mean Jogee will walk free, as the court found he was unquestionably guilty of at least manslaughter, and there was evidence that he could have been guilty of murder, our correspondent said.
Ameen Jogee's mother Rachel Whitehead argued joint enterprise was a "lazy law" that had convicted innocent people
Jogee's mother Rachel Whitehead said she was "absolutely delighted" her son was no longer convicted of murder, and hoped he would soon be free.
She called joint enterprise "a lazy law", saying: "It should never have been invented. It's just been used to convict innocent people of crimes they didn't commit."
Simon Natas, a lawyer who has worked with campaign group Joint Enterprise Not Guilty By Association, said the "historic" ruling would make the law "fairer for everybody".
Lorraine Fraser, whose son Tyrone Clarke was killed by a gang in 2004, said she thought the law should stay in place. Four men were found guilty of Tyrone's murder by joint enterprise.
"They were a pack of animals around him and they all pleaded not guilty in court," she said, adding they should not be allowed to appeal.
In further remarks after publishing the judgement, Lord Neuberger said:
The Supreme Court was sitting in joint session with the Privy Council, which hears final appeals from UK overseas territories, in order to consider a joint enterprise case from Jamaica at the same time.
This means the ruling will apply in most UK overseas common law territories.