Harlem Prep is operated by the charter network Democracy Prep Public Schools.

“After he resigned, Democracy Prep did a routine review of his laptop and was deeply disturbed by suspicious content,” said the spokesman, Jeffrey W. Schneider.

Image Christian Toro, 27, of the Bronx, was arrested Thursday after the police said they found bomb-making supplies in a closet of an apartment he shared with his twin brother, Tyler Toro, who was also arrested. Credit... Facebook

A technician at the charter school examined Mr. Toro’s laptop, and found on its hard drive a copy of a book that contained instructions for making explosives, the complaint said. The school alerted law enforcement officials.

On Jan. 31, the police arrested Christian Toro and charged him with raping a minor. A law enforcement official said that the alleged victim was a student at the school where he worked. “That was something that developed as a result of the investigation of the bomb scare to the school,” according to Mr. Miller. Mr. Toro was released on bail two days later, according to city records. According to Bronx court records, the girl was 15, and Mr. Toro took her home for sex on two occasions.

On Feb. 8, the F.B.I. and police officers interviewed the Toro brothers in their apartment, and Christian Toro told agents that he had come across the explosives book while doing research about the 2013 Boston Marathon bombing and had not meant to download it onto his computer, according to the complaint. He said that he had never built a bomb, the complaint said.

Six days later, on Valentine’s Day, law enforcement agents interviewed students at the charter school, who told them that at least two students had visited the Toros’s apartment to break down the fireworks, storing the powder in containers, the complaint said. It said that the students appeared to have gone to the apartment between October and early January.

On Thursday morning, law enforcement agents executed a search warrant at the brothers’ apartment, where they lived with a female relative.

The complaint said that the agents found bomb-making materials in a closet, including a box containing about 20 pounds of iron oxide, five pounds of aluminum powder, five pounds of potassium nitrate, all materials that can be used to build explosives. It also contained about two pounds of confectioners sugar, which the complaint said can be used as fuel in an explosive. They also found firecrackers and other explosive materials and a bag of metal balls that could have been used as shrapnel in a bomb.