Tokyo • A man shouted “Die!” as he sprayed a flammable liquid all over an animation studio in Japan on Thursday and set the building on fire, killing 33 people as some victims collapsed in a desperate bid to reach the roof.

The president of the studio, Kyoto Animation, said the company had been repeatedly threatened before the attack, but gave no further details.

A series of explosions triggered an inferno that swept through the three-story workspace, emergency services said. Footage showed smoke billowing from the complex on the outskirts of Kyoto as rescue workers rushed to the scene.

The suspect, a 41-year-old man, was in police custody and was being treated for his injuries in a hospital, officials said.

Mikihide Daikoku of the Kyoto City fire department said 33 people have been confirmed dead, and 20 of them were women. Another 36 people were injured and hospitalized, 10 of whom are in serious condition.

Many bodies were found on the top floor, and some of the victims collapsed on the stairs leading to the roof, according to fire officials.

The apparent arson attack was the worst death toll in Japan since a blaze in a Tokyo office building in 2001 claimed 44 lives.

Naoyuki Takao, deputy chief of the Kyoto police investigative department, said the fire took hold immediately after the man ignited what appeared to be gasoline.

About 70 people were inside the complex when the blaze erupted, he said.

It took firefighters about five hours to contain the blaze, the Kyodo news agency reported.

On Twitter, Japanese Prime Minister Shinzo Abe described the attack as murder.

"So many people have lost their life and been injured as a result of the arson and murder case that took place in Kyoto today. It's so tragic that I am at a loss for words," he said.

The blaze broke out around 10:30 a.m. at a three-story studio of Kyoto Animation Co., which is known for producing the TV series "K-On!", "Clannad" and "Miss Kobayashi's Dragon Maid," among others.

Company president, Hideaki Hatta, told reporters that the studio had been receiving threats frequently.

"We have received protests against our company, not a few of them if not on a daily basis. There were murder emails including those which said 'die,' " he told broadcaster NHK.

Kyoto Animation was founded in 1981. In addition to making animation, it publishes novels, comics and visual books, designs characters and manages a school, according to its website.

Crawshaw reported from Hong Kong.