The Government has paid more than £4 million in compensation to people held unlawfully in immigration detention centres in 2014-15.
A Freedom of Information request by the BBC's Victoria Derbyshire programme found that £4-5m was paid out in each of the previous three years as well, totalling £18m.
About 30,000 people pass through the UK's detention centres, also known as immigration removal centres, every year.
They house people the Government is trying to deport, including failed asylum seekers and foreign prisoners.
If judges determine the Government has detained someone unlawfully, it must pay compensation.
In total the Government paid out £4,461,344 in 2011-12, £5,017,971 in 2012-13, £4,775,000 in 2013-14 and £4,000,000 in 2014-15.
Conservative MP Tim Loughton, a member of the Home Affairs Committee, said that last year 60% of the 32,000 people who went through the centres went back into the community, which suggested the system was not working.
He told the BBC: "These are not prisons, they are places purely to hold people who might be at risk of absconding between getting hold of them and putting them on a plane out of the country.
"I think many taxpayers would be greatly annoyed and offended that their money is going not only to look after some of these people who should not be in these detention centres, but we're actually having to pay out compensation because the courts have deemed that they've been detained wrongly as well."
A Home Office spokeswoman insisted detention was "an important part of a firm but fair immigration system, helping to ensure that those with no right to remain in the UK are returned to their home country if they will not leave voluntarily".
She said the Government was committed to treating detainees with respect and proposed reforms after an independent review would lead to a reduction in the number of detainees and the time they spend in detention.
In March, Gilberto Silva Santos, a Brazilian chef, won £136,048 damages at the High Court for false imprisonment and breaches of EU law.
A judge ruled the Home Secretary and her officials treated him in an "outrageously oppressive and unconstitutional way" after he was unlawfully detained for 154 days in 2012, despite being married to an EU national.