The entire courtroom was sent to the cells during a domestic violence hearing when the judge, Robert Restaino, 48, "snapped" and - according to a review of his actions - "engaged in what can only be described as two hours of inexplicable madness".

The State Commission on Judicial Conduct recommended his removal from the bench, saying Restaino acted "without any semblance of a lawful basis" and behaved like a "petty tyrant".

The bizarre episode began on March 11 2005, when the judge was presiding at Niagara Falls City court over a slate of domestic violence cases.

A mobile phone rang and, furious at the intrusion, Restaino demanded to be told who owned it. "Every single person is gong to jail in this courtroom unless I get that instrument now," he said.

"If anybody believes I'm kidding, ask some of the folks that have been here for a while. You are all going."

A security officer was posted at the door while other officers tried to find the phone, but failed.

Finally, the judge scrapped plans to release the defendant in the dock and set bail for all 46 people present at $1,500 (£750).

One man, according to the report, told the judge: "This is not fair to the rest of us." To which the judge replied: "I know it isn't."

Everyone in the courtroom was a defendant, attending court as part of a programme in which domestic violence offenders agree to undergo drug testing and counselling, instead of jail time.

Participants make weekly appearances in court to have their progress monitored and are usually released after each appearance unless they have violated the programme's terms.

All the defendants were taken to the city jail. Fourteen people who could not raise their bail money were shackled and bussed to the county jail.

After receiving inquiries from the local media, the judge ordered their release in the late afternoon.

Restaino, who has worked as a full-time judge since 2002, told the commission he had known that he had no legal basis for his actions and that they had been "improper and inexcusable".

He told the panel he had been under stress in his personal life at the time of the incident.

In the state commission's ruling yesterday, its administrator Robert Tembeckjian said: "The fundamental rights of 46 people were deliberately and methodically violated."

Restaino now has 30 days to appeal the commission's decision. His lawyer told the Associated Press he plans to do so. During an appeal he would remain in office.