British judges can imprison criminals convicted of serious offences for their entire lives, a UK appeals court said.
The ruling put the country at odds with a European decision that the sentences represent inhumane treatment.
Judge John Thomas said in a ruling yesterday: "There are some crimes that are so heinous that the requirements of just punishment encompass passing a sentence which includes a whole life order."
Three men convicted of murder had appealed against the legality of lifetime prison terms.
One of them, Ian McLoughlin, who was jailed for a minimum of 40 years for murder and robbery, had his sentence increased to life by the appeals judges.
The European Court of Human Rights said in July that sentences without the possibility of release constituted inhumane treatment. That ruling was criticised by UK Justice Secretary Chris Grayling, who said it was "hard to understand".
The case is one of many issues that has contributed to the UK's strained relationship with the human rights court and the European Union. Prime Minister David Cameron has pledged to hold a referendum on Britain's EU membership by the end of 2017. And British lawmakers have said they want to curtail the power of European courts.
Attorney General Dominic Grieve said: "As someone who has killed three times, Ian McLoughlin … following yesterday's judgment, has received the sentence that crime required.
"I asked the Court of Appeal to look again at McLoughlin's original sentence because I did not think that the European Court of Human Rights had said anything which prevented our courts from handing down whole-life terms in the most serious cases."
In yesterday's ruling, the British court instructed judges to keep imposing whole-life sentences when appropriate.
"In our judgment, the law of England and Wales ... does provide to an offender 'hope' or the 'possibility' of release in exceptional circumstances," it said.
The ruling by five of the most senior Court of Appeal judges also opened the way for two British Muslim converts who hacked a soldier to death on a London street in May to be sentenced to whole-life terms.
The judge in that case had delayed sentencing Michael Adebolajo and Michael Adebowale, who were convicted in December of Lee Rigby's murder, because he wanted to wait for the Court of Appeal to clarify the position on whole-life sentences.
Conservative Dominic Raab said: "The UK courts have definitively rejected the ludicrous ruling from Strasbourg demanding the most dangerous criminals are given the chance to be freed."
Additional reporting by Reuters