LONG ISLAND, N.Y. (PIX11) — A homeless man allegedly carjacked a woman at gunpoint and then drove the stolen vehicle into a marked police car on Long Island Tuesday night, police said.

Kwaisi McCorvey, 21, allegedly pointed a gun at the driver of a Hyundai SUV after the woman had just pulled into her driveway near Main and Sunset avenues in Wheatley Heights at around 11 p.m., police said.

McCorvey then allegedly drove off in the SUV before cops say they caught up with him about 10 minutes later near Straight Path and Burr’s Lane in Wyandanch. Officers continued following the suspect when McCorvey allegedly rammed into the passenger side of the police car, authorities said.

The suspect allegedly drove three blocks, then got out of the SUV and ran onto the nearby Long Island Rail Road tracks before police nabbed him, officials said.

McCorvey was arrested and charged with robbery, criminal use of a firearm, grand larceny, criminal possession of a weapon, menacing, criminal mischief, two counts of reckless endangerment, reckless driving, and unlawful Fleeing a police officer in a motor vehicle, police said.