A man left in a cold, small and windowless court cell for close to 48 hours was mentally tormented by the experience, his lawyer says.
The Masterton court cell had a toilet and water, but no food or bedding.
"He tells me he was moving around the cell trying to keep warm, trying to sleep using his shoe as a pillow, and definitely the thoughts going through his head were very dark," lawyer Susie Barnes said.
He tried to get the attention of people he heard walking in a carpark near the court, but those attempts failed, she said.
The man, who has name suppression, appeared in the Masterton District Court on Saturday morning for allegedly breaching bail while facing a drink-driving charge.
The sitting Justice of the Peace granted him bail. He was put back into a holding cell while paperwork was filled out, but was forgotten.
Court and police staff found him still in the cell on Monday morning.
Ms Barnes said the court cell was not designed for people to stay overnight.
"It's essentially like a little concrete bunker, there is a kind of concrete seat built into the wall, but there's no mattresses, no blankets, no food, no natural light.
"The fluorescent light had been left on in the cell, but it's difficult to mark the passage of time. He didn't know how long he was going to be there for."
She said he felt a loss of dignity from being "abandoned".
"There is significant mental anguish in there, to do with not knowing, 'When is it going to end?' 'How can I have been forgotten?' He went through some serious mental torment... it was a real internal battle."
Ms Barnes said she questioned why her client was put in a cell after being granted bail.
"They're not usually put back into the cells, although that does happen sometimes, usually there's a room that they can go to.
"Even if they are put into the cells, someone should have been there with him until he was released again."
She said it raised serious questions about the justice system.
"My immediate thought was whether, and to what extent, this incident has arisen as a result of the significant cuts to all areas of the justice system in recent years. Does those cuts to resources lead to an erosion of checks and balances in the system? I think it does."
Police say 'this is on us'
Wairarapa Area Commander Inspector Donna Howard said what happened was unacceptable.
"The gentleman was really distressed, understandably, and really quite overwhelmed."
She apologised to the man and promised to get answers on how it happened to ensure there was no repeat.
"This is on us - it wasn't on him at all," Inspector Howard said.
The man was immediately seen by a doctor and returned home to his family.
The matter has been referred to the Independent Police Conduct Authority. Police would conduct an internal investigation.
Police Minister Paula Bennett said no one in New Zealand should ever be treated in such a way.
Inspector Howard said the police inquiry would include looking at staff training and processes.
Human rights lawyer Michael Bott said the incident breached the man's rights. It was lucky he did not have a medical condition where he needed medication, he said.