A maniac walked into a Lower East Side barbershop Thursday, locked the door behind him and began slashing a man sitting in a barber chair, police said.

The events unfolded at First Choice Barbers on Stanton Street at around 11:15 a.m.

A good Samaritan who was walking by saw what was happening and broke the front window, letting the victim escape, a police source said.

The good Samaritan, an Uber driver from Queens named Julio Guzman, told The Post he saw a number of people outside the shop filming the attack when he launched into action.

“I could hear the man screaming for help. There’s no question that this guy planned on killing him,” Guzman said.

Guzman then used a chair that was sitting next to the shop to break the lock of the door and let the victim escape.

“When I broke open the door, he had him on the floor and was stabbing him in the neck and chest,” Guzman added.

“Thank God that I happened to pass by when I did and that I was able to stop this poor man from suffering,” he said.

The 37-year-old attacker was taken into custody when cops arrived and found him in a back room.

Police said the attack stemmed from an earlier dispute. It wasn’t clear what the dispute was about, cops said.

Additional reporting by Ben Feuerherd