Thirty-six others were injured, some of them critically, in a blaze that sent people scrambling up the stairs toward the roof in a desperate - and futile - attempt to escape what proved to be Japan's deadliest fire in nearly two decades. Others emerged bleeding, blackened and barefoot.
The suspect, identified only a 41-year-old man who did not work for the studio, was injured and taken to a hospital. Police gave no details on the motive, but a witness told Japanese TV that the attacker angrily complained that something of his had been stolen, possibly by the company.
Most of the victims were employees of Kyoto Animation, which does work on movies and TV productions but is best known for its mega-hit stories featuring high school girls. The tales are so popular that fans make pilgrimages to some of the places depicted.
The blaze started in the three-story building in Japan's ancient capital after the attacker sprayed an unidentified liquid accelerant, police and fire officials said.
"There was an explosion, then I heard people shouting, some asking for help," a witness told TBS TV. "Black smoke was rising from windows on upper floors. Ten there was a man struggling to crawl out of the window."
Japanese media reported the fire might have been set near the front door, forcing people to find other ways out.
The building has a spiral staircase that may have allowed flames and smoke to rise quickly to the top floor, NHK noted. Fire expert Yuji Hasemi at Waseda University told NHK that paper drawings and other documents in the studio also may have contributed to the fire's rapid spread.
Firefighters found 33 bodies, 20 of them on the third floor and some on the stairs to the roof, where they had apparently collapsed, Kyoto fire official Kazuhiro Hayashi said. Two were found dead on the first floor, 11 others on the second floor, he said.
A witness who saw the attacker being approached by police told Japanese media that the man admitted spreading gasoline and setting the fire with a lighter. She told NHK public television that the man had burns on his arms and legs and complained that something had been stolen from him.
She told Kyodo News that his hair got singed and his legs were exposed because his jeans were burned below the knees.
"He sounded he had a grudge against the society, and he was talking angrily to the policemen, too, though he was struggling with pain," she told Kyodo News. "He also sounded he had a grudge against Kyoto Animation."
NHK footage also showed sharp knives police had collected from the scene, though it was not clear if they belonged to the attacker.
Survivors said he was screaming "You die!" as he dumped the liquid, according to Japanese media. They said some of the survivors got splashed with the liquid.
Kyoto Animation, better known as KyoAni, was founded in 1981 as an animation and comic book production studio, and its hits include "Lucky Star" of 2008, "K-On!" in 2011 and "Haruhi Suzumiya" in 2009.
The company does not have a major presence outside Japan, though it was hired to do secondary animation work on a 1998 "Pokemon" feature that appeared in U.S. theaters and a "Winnie the Pooh" video.
"My heart is in extreme pain. Why on earth did such violence have to be used?" company president Hideaki Hatta said. Hatta said the company had received anonymous death threats by email in the past, but he did not link them to Thursday's attack.
Anime fans expressed anger, prayed and mourned the victims on social media. A crowd-funding site was set up to help the company rebuild.
Fire officials said more than 70 people were in the building at the time.
The death toll exceeded that of a 2016 attack by a man who stabbed and killed 19 people at a nursing home in Tokyo.
A fire in 2001 in Tokyo's congested Kabukicho entertainment district killed 44 people in the country's worst known case of arson in modern times. Police never announced an arrest in the setting of the blaze, though five people were convicted of negligence.
This story has been corrected to say company president's first name is Hideaki, not Hideki.
Follow Mari Yamaguchi on Twitter at https://www.twitter.com/mariyamaguchi
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.