An investigation has been launched into how a man was left in the cells of Masterton District Court for two nights at the weekend.

Photo: Google Maps

The man appeared in court on Saturday morning on a breach of bail charge and was granted bail by the sitting Justice of the Peace.

However, he was discovered in the cells by police and court staff on Monday morning.

Police said he was immediately seen by a doctor and returned home to his family.

They have apologised to the man and his family for the distress caused.

The Wairarapa Area Commander, Inspector Donna Howard, said the priority was to determine how this happened.

The police were conducting an independent internal investigation and the matter has been referred to the Independent Police Conduct Authority.