After killing his stepfather, Aleksandr Kuznetsov, 54, in the family’s Brooklyn apartment, police said Gelman went to the home of a female acquaintance, Yelena Bulchenko, 20, where he killed her 56-year-old mother.

Gelman then stabbed a man during a carjacking before plowing into pedestrian Stephen Tanenbaum, 62, who died from his injuries. Authorities said he then attacked a livery cab driver and another man in a separate carjacking.

He was subdued by police at the Times Square subway station around the 40th Street and 7th Avenue exits after slashing subway passenger Joseph Lozito, of Philadelphia.

Earlier this year, court documents showed Gelman told police following his arrest that he would beat the charges and spend a few years in a mental hospital.

Gelman decided to change his plea because he wanted to get out of his holding cell and begin serving his time in a permanent facility, his lawyer said. Evidence in the case and a doctor’s opinion would prevent Gelman from arguing he was not guilty by reason of insanity.