An illegal immigrant jailed in the U.K. for a rape attempt will get $33,000 compensation because he was in prison too long.

It is almost $25,000 more than his victim received.

STOCKHOLM TERROR: SWEDEN WILL 'NEVER GO BACK' TO MASS IMMIGRATION, PM REACTS

Bashdar Abdulla Qarani, 36, sneaked into the U.K. in 2005 and racked up a string of offenses, including battery, theft and carrying a knife, but was still allowed to stay.

Then in 2012 he got four years for the South Wales rape bid, making him liable for automatic deportation when freed.

STOCKHOLM ATTACK SUSPECT WAS FAILED ASYLUM-SEEKER; 2ND MAN ARRESTED

The Kurd spent two years inside before being allowed out and was immediately locked up again under immigration laws to prevent him from disappearing.

But Qarani had no ID papers so officials could not prove his nationality and send him home.

Justice Mott at the High Court has ruled officials failed to act swiftly enough, breaching his human rights.

Qarani will get the $33,000 (£27,000) payday for being unlawfully detained for 11 months until his release last December.

His victim would have been entitled to only around $9,300 in compensation.

Click for more from The Sun.