An illegal immigrant, who was jailed for attempted rape, has been given £27,000 in compensation for being in prison too long.

Bashdar Abdulla Qarani, 36, arrived in Britain illegally in 2005, and became a repeat offender, including battery, theft and carrying a knife.

He was allowed to stay in the country and was jailed for four years in 2012 for attempted rape in South Wales.

Mr Justice Mott ruled that his human rights were breached, at the High Court in London

The Kurd, who had no official ID papers, spent two years in prison before he was allowed out on licence but was locked up again to prevent him from disappearing.

Because the authorities could not prove his nationality they were not able to send him to his native country.

Deputy High Court Judge Mr Justice Mott acknowledged that the sex offender had a history of absconding, but ruled that he had been unlawfully detained for 11 months prior to his release last December.

The judge awarded him £27,000 in compensation. He is still due to be deported.

It is not known whether the woman he tried to rape, who cannot be named for legal reasons, received any damages. But under Criminal Injuries Compensation Authority rules, she would only have been entitled to around £7,500.

Charity Voice4Victims said the case showed the ‘imbalance’ between the rights of offenders and victims. The Home Office said it did not comment on individual cases.

Tory MP Philip Hollobone, who wants the Human Rights Act scrapped, called it 'barmy', according to The Sun.

Qarani now has to report to the authorities each week.