A 30-year-old man was arrested on suspicion of attempted murder on Friday after stabbing two police officers inside a courtroom in Sendai.

The stabbing took place shortly after Seiji Yodogawa, who was being tried at the Sendai District Court, was sentenced to a year in prison for taking photos up a woman's skirt.

The injuries to the officers, aged 42 and 44, were not life-threatening.

Because the defendant was freed on bail, he was not checked for weapons before entering the courtroom, the police said.

While his verdict was being read, Yodogawa suddenly turned and crossed over a barrier into the gallery at the back of the room, before brandishing a knife and stabbing the officers, one in the back and one in the face, they said.

He was arrested after spectators in the gallery helped restrain him. He had three fruit knives and two box cutters on him, the police said.

No metal detector was used at the court during the trial.

The defendant was heard criticizing the criminal justice system during the stabbings but has remained silent during questioning.

Yodogawa was being tried for breaking of a local ordinance after arrested earlier this year for allegedly taking upskirt photos of a high school girl on a train platform in Sendai.