At his office near the Empire State Building, Rex Heuermann was a master of the meticulous: a veteran architectural consultant and a self-styled expert at navigating the intricacies of New York City’s building code. He impressed some clients and drove others crazy with his fine-toothed directives.

At home in Massapequa Park on Long Island, while some neighbors saw Mr. Heuermann as just another commuter in a suit, others found him a figure of menace. He glowered at neighbors while swinging an ax in the front yard of a low-slung, dilapidated house that parents cautioned their children to avoid on Halloween. He was kicked out of a Whole Foods for stealing fruit.

“We would cross the street,” said Nicholas Ferchaw, 24, a neighbor. “He was somebody you don’t want to approach.”

On Friday, Suffolk County prosecutors said that residents of Massapequa Park had a serial killer living in their midst. They accused Mr. Heuermann, 59, of leaving a quarter-mile trail of young women’s bodies on the South Shore of Long Island in what came to be known as the Gilgo Beach Killings. Yet he was so careful in covering his tracks, they said, that it took them nearly 15 years to arrest him.

Mr. Heuermann’s friends and clients in the real estate business were flabbergasted.

His neighbor Mr. Ferchaw said, “I wasn’t surprised at all — because of all the creepiness.”

A yearbook photo of Mr. Heuermann from Berner High School in Massapequa.Credit…The New York Times

Mr. Heuermann, who was arrested in Midtown on Thursday night, was charged Friday with three counts of first-degree murder and ordered held without bail during a brief appearance at a courthouse in Suffolk County. His lawyer said outside the courthouse that Mr. Heuermann denied committing the killings.

If convicted of these crimes, Mr. Heuermann would join the ranks of serial killers who led double lives, the other one quite mundane. John Wayne Gacy was a construction contractor in Illinois. Richard Cottingham, known as the Torso Killer, was a computer operator for a New Jersey insurance company.

In a video interview posted on YouTube last year and conducted at his entirely unremarkable-looking office on Fifth Avenue, Mr. Heuermann — tall and heavyset, sporting a toupee-like 1970s haircut and a blue dress shirt with a pen peeking from the pocket — comes across as a recognizable character: the scrappy, street-smart Noo Yawker, the I-got-a-guy guy.

“When a job that should have been routine suddenly becomes not routine,” he tells the interviewer, Antoine Amira, “I get the phone call.”

According to his résumé and the website of his company, RH Consultants & Associates, Mr. Heuermann’s customers included American Airlines, Catholic Charities, and the city’s own Department of Environmental Protection. He represented clients before the Landmark Preservation Commission many times and claimed credit for hundreds of successful applications before city agencies.

Steve Kramberg, a property manager in Brooklyn who worked with Mr. Heuermann for about 30 years, called him “a gem to deal with, highly knowledgeable.” Mr. Heuermann was “a big goofy guy, a little bit on the nerdy side” who worked long hours and was available day and night, Mr. Kramberg said. But he was also devoted to his wife, who Mr. Kramberg said had health problems, and to his elderly mother.

In Massapequa Park, a tightly gridded village of neat homes with manicured lawns, Mr. Heuermann, the son of an aerospace engineer, lived in the house that he grew up in and tinkered with furniture in his father’s old workshop. A man who went to high school with him said he was bullied as a teenager but sometimes fought back. In 1990, he married an executive at an office supply company. He has a daughter who works at his firm.

Mr. Ferchaw recounted several run-ins with his neighbor, none pleasant. There was the time he said hello to Mr. Heuermann as he was cutting wood and Mr. Heuermann responded by silently glaring back between chops of his splitting maul. Other times he would be seated beside his stacked wood on the porch watching an old television.

Mike Schmidt, who has lived in the neighborhood for 10 years, has a friend who lives behind Mr. Heuermann. Sometimes Mr. Schmidt would visit his buddy, have a few beers in the backyard, look out at the sagging Heuermann house, “and say ‘He probably has bodies there.’”

Last Halloween, Mr. Schmidt and his friend resolved to take their kids trick-or-treating at Mr. Heuermann’s house, just to get a look inside. They were surprised when Mr. Heuermann himself answered the door and gave each child a small plastic pumpkin overflowing with candy.

When Mr. Schmidt’s wife learned where the candy came from, she made him throw it out.

At work, Mr. Heuermann’s punctilious approach rubbed some people the wrong way. Kelly Parisi, a former president of the co-op board at a building in Brooklyn Heights that hired Mr. Heuermann to oversee renovations, said he was “adversarial with everyone” and so “overly fastidious” that the board eventually fired him.

Paul Teitelbaum, another former president of the building’s board, described him as “a really kind of cold and distant person, kind of creepy.” He added, “There was a swagger — ‘I’m the expert, you’re lucky to have me.’”

But one man’s arrogant demands were another’s eye for detail. “He was very good at shepherding things through,” Mr. Kramberg said.

According to the timeline released by prosecutors and to Buildings Department and court records, Mr. Heuermann kept up his busy work schedule even as victims were vanishing.

In 2009, prosecutors said, after killing Melissa Barthelemy, a 24-year-old who worked as an escort, Mr. Heuermann made a series of taunting calls to her family, during lunchtime and after work hours, from locations near his office

In June 2010, about two weeks after Megan Waterman, a 22-year-old from Maine, was last seen alive, Mr. Heuermann filed an application to install a new fire escape at a building in Cobble Hill, Brooklyn. In August of that year, he filed an application to repair the terra cotta and repoint the bricks in a building on the Upper West Side, nine days before Amber Lynn Costello, 27, disappeared near her home a few miles from Mr. Heuermann’s.

On March 9, 2022, as the investigative dragnet was tightening, Mr. Heuermann was writing a typically detailed letter to a lawyer concerning a project on West 71st Street:

It appears that from my walk though, the drain line is above the interior floor slab and if the trench drain is placed below this level, it would not be able to drain by gravity,” he wrote. “I would strongly recommend an investigation into the use of negative side waterproofing at this site.”

Five days after that, investigators figured out that Mr. Heuermann had owned the same model pickup truck that a witness said Ms. Costello’s killer had driven. Two weeks later, prosecutors said, Mr. Heuermann googled “Long Island serial killer” and viewed an article headlined “New Task Force Aims to Solve Long Island Serial Killer Case.’”

It was late last summer that Mr. Heuermann, sweaty and wearing a dingy T-shirt and shorts, was spotted at the Massapequa Park Whole Foods pilfering clementines from a bowl put out for children.

“He took three and put them in his pocket, then he took more,” said Tara Alonzo, a clerk at the store. After a few more rounds she called him out. “I said, ‘Sir, those are for the kids,’” she recalled. She said Mr. Heuermann yelled back and became so heated that her manager escorted him out. She did not see his face again until it appeared on TV on Friday.

“My co-worker said, ‘That’s the orange guy!’”

Mr. Kramberg said he had talked to Mr. Heuermann on the phone Thursday evening. He was his usual chatty self, cracking jokes.

“That must have been right before he left the office and they arrested him,” Mr. Kramberg said.

Ginia BellafanteCorey Kilgannon and Michael Wilson contributed reporting. Jack Begg contributed research.