A man who was jailed for at least two and a half years in 2008 is to be released after spending almost 16 years in prison.
Leighton Williams was given an open-ended jail term for drunkenly attacking a man in a park in Caerphilly in 2007 when he was 19 years old.
The Court of Appeal changed his sentence on Thursday.
He was initially handed what is known as an imprisonment for public protection (IPP) sentence.
They meant prisoners could remain in detention after serving their minimum term if they were still deemed a serious risk to the public – but they were abolished in 2012.
Williams last year filed an appeal and three senior judges have now found in his favour, which means he will be immediately released.
He attended the hearing through a video link from HMP Parc, near Bridgend.
Cheshire: Driver who reached speeds of 93mph jailed for killing two women
Canaletto painting returns to Wales 80 years after mine protected it from Nazi wartime bombing in London
Welsh parliament votes to increase Senedd members by more than 50%
He wept after the judges gave their ruling, as Lord Justice Popplewell said it was “in the interests of justice” to allow the appeal.
Please use Chrome browser for a more accessible video player
“We will substitute a determinate sentence of five years’ detention in a young offender institution, which will result in his immediate release,” he said.
Williams was given the IPP sentence at Cardiff Crown Court in June 2008 for grievous bodily harm with intent.
His victim was left with a fractured jaw, cheekbone and eye socket after the attack.
Lord Justice Popplewell said the judge who initially sentenced Williams believed it was necessary due to a previous conviction for grievous bodily harm.
But he said the judge had not considered Williams’ age at the time of the offence.
Read more:
Keeping people in prison on IPP sentences costs £1bn since 2012
Prisoner serving indefinite sentence has release bid rejected
Reforms announced to address ‘stain’ of IPP sentences
Be the first to get Breaking News
Install the Sky News app for free
Please use Chrome browser for a more accessible video player
More than 1,000 people remain locked up after being given an IPP sentence, despite their being scrapped more than a decade ago.
There have been calls for all prisoners serving IPP sentences to be resentenced, but the government has so far resisted those calls.