It was nearly 8 p.m. on Wednesday when Mr. Lamparello, a 37-year-old graduate student and lecturer on philosophy, entered St. Patrick’s Cathedral in Midtown Manhattan toting two gasoline cans, lighter fluid and lighters, the police said.

Hours before, he had purchased a $2,800, one-way plane ticket to Rome, which was set to depart the next day.

Mr. Lamparello was about 20 feet into the church when ushers approached him and said he could not be inside the building with the cans of gasoline, the police said. He explained that he was trying to take a shortcut through the iconic sanctuary to reach his van, which he claimed had run out of gas.

Mr. Lamparello’s gold minivan, though, turned out not to be out of fuel, the police said, and a stroll through St. Patrick’s was hardly a shortcut.

Denied entry, Mr. Lamparello left the sanctuary, sloshing gasoline on the floor as he went, the police said. He was stopped outside the church by police officers, who noticed the twin gas cans.

The incident came just before Easter and two days after a devastating fire tore through the Cathedral of Notre-Dame in Paris.

Image

The police stand guard outside St. Patrick’s Cathedral on Thursday. Ushers on Wednesday had directed Mr. Lamparello to leave the church.CreditKevin Hagen for The New York Times

Mr. Lamparello, who has addresses in New Jersey and in Brooklyn, was taken into custody Wednesday night and questioned by detectives, including officers from the Police Department’s intelligence division and the Joint Terrorism Task Force. He was being held on charges of attempted arson and reckless endangerment, senior police officials said.

But on Thursday afternoon, he was transported from the Midtown North Precinct to Bellevue Hospital Center for a psychiatric evaluation, the police said, and it remained unclear when he would appear in court.

It was the second church-related arrest this week for Mr. Lamparello. On Monday night, he was arrested inside Newark’s Sacred Heart Cathedral after he refused to leave the sanctuary. He told officers the church was a house of God and should be open at all hours before throwing himself on the floor and vowing to stay.

“Said, ‘If you want me to leave, you’ll have to take me out in handcuffs,’” Armando B. Fontoura, the Essex County sheriff, said. He described Mr. Lamparello as “very respectful,” if obstinate.

Mr. Lamparello was taken to a police station that evening and charged with resisting arrest, defiant trespassing and interfering with the administration of law.

He was evaluated by emergency medical technicians, who found nothing wrong with him, Sheriff Fontoura said. His mother escorted him that night from the precinct to his parents’ home in Hasbrouck Heights, N.J., he said.

It remains unclear what may have driven Mr. Lamparello to go to St. Patrick’s Cathedral on Wednesday. Police officials would not say what, if any, motive he disclosed to officers.

“There doesn’t appear to be any connection to a terror group,” said John Miller, the Police Department’s deputy commissioner of intelligence and counterterrorism.

Mr. Lamparello is a doctoral candidate in philosophy at the City University of New York. His mother told the New Jersey authorities he had an apartment in New York City.

Image

Mr. Lamparello carried two gas cans, two bottles of lighter fluid and two lighters into St. Patrick’s Cathedral, the police said.CreditNew York Police Department

He was a 2004 graduate of Boston College and was listed as teaching courses at Brooklyn College this spring. The police said Mr. Lamparello also taught at Seton Hall University in New Jersey.

He had written and published a book, “Reason and Counterpoint,” in 2016. His online biography on Amazon.com suggests an interest in questions of religion and higher powers; it said he was working on a book-length project that would wrestle with the existence of God.

At least one of the courses he has taught, Introduction to the Problems of Philosophy, touched on religion.

The course included “such topics as the nature and scope of knowledge, meaning and verification, the existence of God, determinism and free will, the mind-body problem, and the nature of moral judgments,” according to an online course description for Brooklyn College.

Ali Watkins is a reporter on the Metro Desk, covering courts and social services. Previously, she covered national security in Washington for The Times, BuzzFeed and McClatchy Newspapers. @AliWatkins

A version of this article appears in print on , on Page A19 of the New York edition with the headline: Man Detained at St. Patrick’s Was Arrested at Another Church Days Ago. Order Reprints | Today’s Paper | Subscribe