[The latest: The man was identified as a philosophy teacher who has had run-ins with law enforcement.]

A 37-year-old New Jersey man carrying a pair of full two-gallon cans of gasoline was arrested on Wednesday night after entering St. Patrick’s Cathedral in New York, the police said.

The man entered the cathedral just before 8 p.m. but was turned away by a church security officer, according to John Miller, the Police Department’s deputy commissioner of intelligence and counterterrorism. As the man exited, some gasoline spilled on the floor.

The security officer then notified two police officers outside the cathedral, who caught up to the man and began to question him. While he was cooperative, his answers were inconsistent and evasive, Mr. Miller said at a news conference.