An Upper West Side man surrendered to police on Wednesday, about 24 hours after he allegedly attacked his girlfriend with a hammer and set her on fire, law enforcement sources said.

Larry McGloster, 26, turned himself in to cops in Westchester County before NYPD detectives went up to get him, law enforcement sources said.

He was being questioned at the 24th Precinct station house on Wednesday night.

Just before noon on Tuesday, McGloster allegedly struck his 32-year-old girlfriend with a hammer, doused her with an accelerant and lit her on fire, law enforcement sources said.

The horrific attack happened inside his apartment at Frederick Douglass Houses at 825 Columbus Ave. The critically injured woman lives in Bed-Stuy in Brooklyn.

McGloster has been charged with attempted murder, assault, arson and criminal possession of weapon.