Law enforcement respond to the University of North Carolina-Chapel Hill campus in Chapel Hill, N.C., Aug. 28, 2023, after the university locked down and warned of an armed person on campus. A University of North Carolina graduate student charged with fatally shooting his faculty adviser on campus five months ago had bought a pistol online and visited a gun range the day before the professor was killed, according to information from federal search warrants.

Law enforcement respond to the University of North Carolina-Chapel Hill campus in Chapel Hill, N.C., Aug. 28, 2023, after the university locked down and warned of an armed person on campus. A University of North Carolina graduate student charged with fatally shooting his faculty adviser on campus five months ago had bought a pistol online and visited a gun range the day before the professor was killed, according to information from federal search warrants.

<p>FILE - Law enforcement and first responders gather on South Street near the Bell Tower on the University of North Carolina-Chapel Hill campus in Chapel Hill, N.C., Aug. 28, 2023, after a report of an “armed and dangerous person” on campus. A University of North Carolina graduate student charged with fatally shooting his faculty adviser on campus five months ago had bought a pistol online and visited a gun range the day before the professor was killed, according to information from federal search warrants. (Kaitlin McKeown/The News & Observer via AP, File)</p>
                                 <p>Kaitlin McKeown | The News & Observer via AP</p>

FILE - Law enforcement and first responders gather on South Street near the Bell Tower on the University of North Carolina-Chapel Hill campus in Chapel Hill, N.C., Aug. 28, 2023, after a report of an “armed and dangerous person” on campus. A University of North Carolina graduate student charged with fatally shooting his faculty adviser on campus five months ago had bought a pistol online and visited a gun range the day before the professor was killed, according to information from federal search warrants. (Kaitlin McKeown/The News & Observer via AP, File)

Kaitlin McKeown | The News & Observer via AP

CHAPEL HILL (AP) — A University of North Carolina graduate student charged with fatally shooting his faculty adviser on campus five months ago had visited a gun range the day before the professor was killed and had bought a pistol, according to information from federal search warrants.

Tailei Qi, 35, was arrested in a residential area less than two hours after the Aug. 28 shooting of Zijie Yan inside a laboratory building at the University of North Carolina, Chapel Hill.

Qi, charged with first-degree murder and a gun-possession count, was found unfit for trial after a judge said two mental evaluations determined he likely suffers from untreated schizophrenia. Qi was ordered moved to a state mental hospital. His legal situation could change if his condition improves.

The search warrant applications reveal more details about Qi and what authorities say happened, The News & Observer of Raleigh reported. An FBI agent in the days after the shooting sought the warrants to search Qi’s phone, apartment and car. Warrant documents stating that searches were carried out were filed in court last week.

The shooting resulted in an hourslong campus lockdown and search for the suspect that frightened students and faculty, who had just returned to the university system’s flagship campus for the start of the fall semester.

The warrants said a witness inside Caudill Laboratories heard an argument between Qi and Yan, a professor in the Department of Applied Physical Sciences, followed by five gunshots. Officers found Yan dead in an office area, and the witness saw Qi walking by with a gun in his hand, according to the warrants, which also said other witnesses identified the shooter as Qi.

Authorities found Qi about 2 miles (3.2 kilometers) from the building. Qi, who is from China, denied owning a pistol but said he rented and shot one at a firing range with an instructor two weeks earlier, the warrants state.

But a search of Qi’s apartment uncovered a notebook with information that led agents to identify someone who then told authorities he had sold a 9 mm firearm a few days earlier to a man he identified from a photograph as Qi, the legal documents say.

Qi’s student visa prevented him from legally possessing a firearm, the warrants state. Qi’s arrest warrant from August accused him of possessing a 9 mm pistol unlawfully on campus.

Staff at the shooting range in nearby Wake County said Qi visited the range on Aug. 17 and Aug. 27, according to the documents, and said Qi rented a pistol that was similar to the firearm that it’s believed he had purchased. Qi had purchased 9 mm ammunition at the range, a warrant states, and police recovered shell casings from 9 mm ammunition at the site of the killing.

Authorities have not released a motive for the shooting and said previously they had not found the weapon used in the killing. In paperwork he filled out to use the range, Qi listed Yan as his emergency contact, according to a search warrant.