An American man who had been convicted of growing marijuana in Taiwan killed himself in a courtroom after he was sentenced to a four-year prison term, according to court officials.

The man, Tyrel Martin Marhanka, 41, slashed his throat with a pair of scissors on Thursday, the Changhua District Court said in a written statement. He was rushed to a hospital but could not be saved.

He had been convicted of growing marijuana at his home in Changhua, in central Taiwan, and of importing marijuana and opium poppy seeds. A prison term of up to seven years was possible, but the court gave him the lesser sentence because he had not sold marijuana and was growing it for his own use.

When a court interpreter told Mr. Marhanka the sentence, he replied, “Four years?” The Taipei Times reported, quoting witnesses. He said he did not want to appeal.

“I don’t want to live anymore,” he said, taking out two metal objects, apparently a disassembled pair of scissors, and then cutting his neck, the newspaper reported.

The court expressed “deep regret.” An initial inquiry found a magazine that he seemed to have used to conceal the scissors. A metal detector apparently did not uncover them. The court said that the building did not have enough space for a more advanced scanner but that it would install X-ray machines in a new building.

Mr. Marhanka was not in detention before the hearing and did not show suicidal impulses, the court said. Mr. Marhanka had a wife and two children in Taiwan and had lived there for several years. He had worked as an English teacher, but his neighbors said he lost his job after he was charged in the marijuana case, the Central News Agency reported.

His death is likely to raise questions about security in Taiwan’s judicial system. Last year, inmates in southern Taiwan used scissors from a workshop to take guards hostage. They broke into a prison armory to seize firearms, which six inmates used to kill themselves.