A man was nabbed Wednesday night walking into St. Patrick’s Cathedral with four gallons of gasoline, lighter fluid and lighters, police said.

Marc Lamparello, 37, of New Jersey, entered the historic Midtown church about 8 p.m. with the flammable paraphernalia, but was quickly intercepted by church security, law enforcement sources said.

He turned around, but spilled some gas in the process, prompting the guards to alert counter-terrorism cops stationed outside the church.

When questioned, Lamparello claimed he was simply cutting through the church to get to Madison Avenue because his van, which was parked outside on Fifth Avenue, ran out of gas, NYPD Deputy Commissioner for Intelligence and Counterterrorism John Miller said at a press conference outside St. Pat’s Wednesday night.

But his tan mini-van was not out of fuel and his “answers were inconsistent and evasive, although he remained conversational with them and cooperative,” Miller said.

“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 that we would have great concern over,” Miller said.

The incident is “very suspicious” — especially given it came just two days after Paris’ Notre Dame cathedral erupted in flames, Miller noted.

“His story is not consistent, so he’s having conversations with the detectives right now. I think if you add to that the events at the iconic location of the fire in Notre Dame this week and all the publicity around that,” he said.

Lamparello is a CUNY student seeking his Ph.D. in philosophy and has done stints as an adjunct lecturer at Lehman College, a police source said.

Cops initially recovered two red, 2-gallon cans of gasoline, as well as a bag containing two bottles of Kingsford lighter fluid and a pair of barbecue lighters, officials said.

A third gasoline can was later found inside Lamparello’s van, law enforcement sources said.

By sifting through surveillance video, authorities determined that Lamparello parked outside the church about 6:30 p.m., police sources said.

He then milled about before collecting the flammable items from his van around 7:30 p.m. A half-hour later he walked into the church, sources added.

“That’s insane. People are crazy,” said a passerby who gave the name Alana and said she is a Catholic.

Lamparello is “known to police,” according to Miller. He has two prior arrests in New Jersey for criminal trespass and public drunkenness, sources added.

He was taken to Midtown North for questioning.

Mayor Bill de Blasio Wednesday night praised the NYPD’s quick response.

“Thank you to @NYPDnews for the swift response. We are all focused on keeping our congregations and houses of worship safe as they celebrate this Holy Week,” de Blasio tweeted.

The FBI’s Joint Terrorism Task Force is assisting the NYPD in the investigation, though there was no immediate indication it was terror-related, Miller said.

Additional reporting by Adam Schrader