Marc Lamparello also had a flight booked to Rome for the next day and a hotel within 20 minutes' drive of the Vatican, the judge was told.
Prosecutor David Stuart said Mr Lamparello was at the church the day before as well.
The accused walked 20 feet into the building, at which point he was told by church ushers that he couldn't be in there with petrol cans. He said he was taking a shortcut to his van, which had run out of gas.
Mr Lamparello, a 37 year-old philosophy teacher, watched the proceedings with his lawyer via video link from Bellevue Hospital Center where he has been ordered to take a psychiatric review.
He entered no plea at the hearing.
Mr Stuart said he had spent considerable time planning the operation.
St Patrick's Cathedral
Mr Lamperallo's lawyer said he was suffering a mental breakdown and that the events leading up to and including 17th April support that claim.
Two days before he went to St Patrick's, he refused to leave the sanctuary of Newark's Sacred Heart Cathedral in New Jersey.
In December, he told police headquarters that he was being stalked by police.
Stay up to date with the latest news stories from a Christian perspective. Sign up to our daily newsletter and receive more stories like this straight to your inbox every morning.