When a security officer at the cathedral stopped the 37-year-old man, he left the church and was detained shortly afterward by counterterrorism officers, NYPD's John Miller said at a news conference.
The man, who is from New Jersey and is known to police, spilled some of the gasoline as the security officer stopped him in the church and forced him to turn around, Miller said.
"It's hard to say exactly what his intentions were but I think the totality of circumstances of an individual walking into an iconic location like St. Patrick's Cathedral, carrying over four gallons of gasoline, two bottles of lighter fluid and lighters is something we would have great concern over," Miller said.
Security officers are stationed at each entrance and noticed him when he came through the main entrance, according to Kevin Donohue, director of building operations at St. Patrick's Cathedral.
"This gentleman walked in the door, and he caught the eye right away, and he was confronted," Donohue said.
Before entering the church, the man retrieved the items from a minivan he had parked near the church, Miller said. The NYPD swept that vehicle and did not find any additional materials.
The man initially told officers he was cutting through the cathedral to get to Madison Avenue and that his car had run out of gas, but Miller said when officers checked his car, it had gas.
"Upon questioning him, his explanation for being in the area wasn't legit, and he was taken into custody," Donohue said.
The man has not been identified but when he is charged with a crime, police will release his identity, Miller added.
Authorities described him as emotionally disturbed but said it's too early to tell what his motive was or whether it's connected to terrorism.
Nobody was injured in the incident and police are investigating. St. Patrick's Cathedral, which opened its doors in 1879, is a prominent landmark in the city.
The incident comes days after the historic Notre Dame Cathedral in Paris burned in what officials say could be an accident related to renovation work. Prosecutors investigating the causes of the inferno have interviewed construction workers and security staff as more details emerged about the effort to contain the blaze.
Notre Dame fundraising efforts inspire people to donate nearly $2 million to rebuild burned Louisiana churches
In France, security guards at the 850-year-old cathedral first heard the fire alarm at 6:20 p.m. local time on Monday, and evacuated the cathedral even though they didn't see any sign of fire, a spokesman for the Paris Fire Brigade said.
The alarm sounded again some 20 minutes later, at which point the cathedral's security officers noticed the fire.