BANGOR, Maine — A local high school teacher who died of apparent suicide Saturday in the wake of a police investigation solicited nude photographs from one of his female students, according to court documents.

Jeremiah Gorman, 35, of Bangor, who taught social science at John Bapst Memorial High School, was being investigated by local police for sexual exploitation of a minor because of those photos, according to the affidavit, which was used to obtain a search warrant.

Mel MacKay, head of school at John Bapst, said Saturday in an email to parents that Gorman was being investigated for possession of child pornography. The court document does not list that as the offense but states “persons who possess or disseminate child pornography via the Internet usually retain those images for a very long period of time.”

Gorman was found dead Saturday at a local hotel, according to the email MacKay sent to parents over the weekend.

Gorman allegedly used more than 25 screen names on at least two different social media apps to communicate with the victim, the affidavit said. In several of the screenshots included in the document, Gorman was seeking out younger women.

At the time of his death, he had not been charged with a crime, according to Bangor police. The investigation into Gorman’s activities and the forensic analysis of his computers, flash drives, cameras and other devices is continuing.

Sgt. Tim Cotton declined Monday to comment on the investigation or about where and how Gorman died.

The investigation into Gorman began March 3 when a Penobscot County sheriff’s deputy received a complaint from the girl, who admitted sending sexually explicit photos of herself to a man, according to the affidavit. When the girl, who is not named in the affidavit, met with a detective the next day, she gave him information about two males with whom she had been communicating — “Mark” and “Teacher.”

She described “Mark” as a teenage male who attended a local high school, but said she did not know his real identity, the affidavit said. The girl told police she suspected “Teacher” was one of three male teachers at Bapst.

“[She] did establish contact with ‘Teacher’ and began to talk with him about things going on at school and the people that went there,” Detective Rick Canarr wrote in the affidavit. “Almost immediately ‘Teacher’ requested nude photographs of her and when she messaged Mark about the requests, Mark encouraged her to send the pictures and she did.”

The user accounts for “Mark” and “Teacher” later were traced to Gorman’s IP address, according to the affidavit.

One of the text messages found on the girl’s phone from Mark, said if “she engaged in sexual acts with ‘Teacher,’ she would definitely ‘get an A,’” the affidavit said.

Investigators met with school officials March 11. Two days later, subpoenas were issued to Snapchat Inc. and Whisper, the two apps on which Gorman and the girl had communicated.

The affidavit was filed Friday at the Penobscot Judicial Center, the same day Gorman’s home was searched.

Sexual exploitation of a minor is a Class B crime that carries a prison sentence of up to 10 years and a fine of up to $20,000.

Friends and acquaintances have declined to comment on Gorman’s death, but he was well-known throughout the Bangor community. Last year, Gorman worked with others to create a “Bangor Gets Happy” video that featured more than 40 area businesses, according to the Bangor Daily News archives.

The video showed Bangor residents, business owners, members of city-based organizations and visitors to the Queen City dancing to Pharrell Williams’ hit “Happy,” in the style of other “Happy” videos from all over the world.

Gorman earned his bachelor’s and master’s degrees in history from Miami University in Oxford, Ohio, according to information on John Bapst’s website.