The grisly murders have prompted calls for the city to do more to help an estimated 3,600 people living unsheltered and to address mental illness.

Here’s what we know about Mr. Santos:

Early Saturday morning, Mr. Santos, walked through Chinatown stalking men who lay on the ground. He swung a three-foot, 15-pound metal pipe at their heads, killing four men, including 83-year-old Chuen Kwok, whose surname is sometimes spell Kok. Another man was critically injured. The first attack happened at about 1:30 a.m., when a homeless man asleep in front of 17 East Broadway was struck in the head and killed, according to a criminal complaint. Minutes later, three men were attacked with a metal bar in front of a pharmacy at 2 East Broadway near Chatham Square, an attack filmed by a security camera. Two died. Then at about 1:50 a.m., a fifth sleeping man was clubbed a block north at Doyers Street and East Broadway; he also died. Two passers-by witnessed the last attack and called the police, who arrested Mr. Santos at about 2 a.m. at Canal and Mulberry Streets, still carrying a metal bar with blood and hair sticking to it.

People who knew Mr. Santos in the Bronx neighborhood where his mother lives said he appeared to be unraveling mentally in recent weeks. He had been doing odd jobs for his mother’s neighbors, Lydia and Segundo Segarra, cleaning up debris in their yard, but stopped showing up in late September. “He seemed lost,” Mr. Segarra said. “He would forget that he just saw you.” The day before the attacks, residents of the building where Mr. Santos’s mother lived saw him lying down in an empty hallway, possibly trying to get his mother's attention to let him in. Mr. Santos, generally quiet and affable toward neighbors, was withdrawn. “He wasn’t making eye contact,” said Candy Santos, 41, who had no relation. “He was just laying there. There was something in his eyes that felt different. It’s like he wasn’t there.”

Mr. Santos had previously been accused in a string of violent assaults targeting random people. Much of his record is sealed, but he had most recently been arrested in May, when he was kicked out of a men’s shelter in East Flatbush. He pummeled another 24-year-old shelter resident in the face. That case was dismissed. A year ago, Mr. Santos choked a 55-year-old man and bit his breast at an employment agency in the garment district in Manhattan, the police said. He had leapt across the counter to attack the man. Four days later, he was on a northbound Q train, between Canal Street and Union Square stations, when he yelled out, “We need to stop it!” and punched a 33-year-man in the eye. He was charged with both assaults.

There were more incidents this year. On Feb. 25, police officers spotted Mr. Santos enter the Hoyt-Schermerhorn subway station in Brooklyn through an exit gate without paying and arrested him. At the precinct, he spat on the floor toward a sergeant, the police said. Less than a week later, he was arrested on a charge of groping a 19-year-old woman at the front door of her apartment building in Jamaica, Queens.

His family in the Bronx had kicked him out. His mother, Fioraliza Rodriguez, told The Daily News she was afraid of him. “I never thought he would kill someone,” she said. “I was afraid of him, though, because he punched me. That’s when I told him to get out of my house.” The Daily News also reported that Mr. Santos broke his grandfather’s nose in 2016, and sneaked into the family’s home last week and stole a watch, a phone and three phone chargers.

Denielda Jordan, a neighbor of Ms. Rodriguez, observed Ms. Rodriguez refusing to let Mr. Santos into her apartment. But the mother would give food to her son. “If your mother doesn’t let you in the house, there’s a problem,” Ms. Jordan, 58, told The New York Times. The Post reported that Mr. Santos had been living in squalor inside an abandoned house at 691 East 183d Street, near his mother’s apartment.

Mr. Santos most recently worked in construction, a job he lost because of excessive drug use, said Nelson Reyes, also a neighbor of Ms. Rodriguez. “He started smoking crack,” said Mr. Reyes, 39, in an interview with The Times. “Then he started losing his mind.”