Endean Palmer, 30, was in custody in relation to suspicions of assault and false imprisonment when he became ill, in August of 2018, and was taken to Princess Royal Hospital.
There is no suggestion his falling ill was related to police conduct.
He left the hospital – and was subsequently charged with escaping from lawful custody.
But it was ruled this week that Mr Palmer should have been released before he took ill, as it had become apparent he had no case to answer on the assault or false imprisonment charges against his partner at the time.
The woman denied his involvement on multiple occasions and without him being present provided a detailed alternative explanation for the events that led to his arrest, saying it was a "misunderstanding".
Shrewsbury Crown Court heard on Wednesday from prosecution counsel Mr Philip Beardwell and Mr Palmer's representative Mr Rob Edwards, who questioned an officer in the case.
An investigation began on August 8, 2018, after West Mercia Police received a message from Hertfordshire Police, the court heard.
Judge Anthony Lowe, having heard from Mr Beardwell and the officer, said that the woman had sent a picture of bruises and a message to her brother in Hertfordshire saying she had been "messed up" by Mr Palmer.
That led to a crime being reported and police visiting the house they stayed in, where the woman denied Mr Palmer had committed any crimes.
They visited again and she again denied any wrongdoing on his part, before explaining that the bruises had been caused by a "Chinese female" days earlier.
Judge Lowe said: "She found out Mr Palmer had been cheating on her, she was upset and wanted to leave the address.
"She texted a picture of her injuries to her brother to come and get her."
On the second occasion, Mr Palmer was arrested and taken to Malinsgate Police Station for an interview. It was while he was in the station he fell ill and was taken to Princess Royal Hospital in Telford.
He left the hospital and was subsequently charged with escaping custody – he was due to stand trial this week for that charge before the arrest was found to have been unlawful.
Judge Lowe concluded that the officers should have decided there were no legal grounds for an arrest before he fell ill.
"I do find that... Mr Palmer was being unlawfully detained and therefore could not commit the offence of escaping.
"Nothing I have said is meant to cause the police who face these difficult situations to think 'crikey, if we get this wrong we're going to be hauled before the courts for unlawful arrest or get sued'."
The judge told Mr Palmer he was free to go and said he hoped that he would not believe he was unfairly targeted by police because of his skin colour, saying that the officers were faced with a difficult situation in his case.
Mr Palmer thanked the judge and left the dock.