They called it the polygon.

Using phone records and a sophisticated system that maps the reach of cell towers, a team of investigators had drawn the irregular shape across a map of tree-lined streets in the Long Island suburb of Massapequa Park. By 2021, the investigators had been able to shrink the polygon so that it covered only several hundred homes.

In one of those homes, the investigators believed, lived a serial killer.

A decade before, 11 bodies had been found in the underbrush around Gilgo Beach, a remote stretch of sand five miles away on the South Shore. Four women had been bound with tape or belts or wrapped in shrouds of camouflage-patterned burlap, the sort that hunters use for blinds. They had worked as escorts and had gone missing after going to meet a client.

Each, shortly before she disappeared, had been in contact with a different disposable cellphone. Investigators eventually determined that during the workday, some of the phones had been in a small area of Midtown Manhattan near Penn Station, and at night they pinged in the polygon, mirroring the tidal movements of the 150,000 Long Island residents who head into Manhattan each day.

Last Friday, Suffolk County authorities announced that they had arrested a man who they believed had killed the four women: Rex Heuermann, a 59-year-old architect who had an office near Penn Station and lived on a quiet street right where they had expected to find him. He was charged with three of the murders, to which he has pleaded not guilty, and was named as the prime suspect in the fourth.

The arrest ended years of anguish for some of the victims’ families. But the investigation also raised an unsettling question: Could the authorities have solved the case years earlier?

The following account is drawn from a 32-page bail application and interviews with current and former investigators and Suffolk County’s top law enforcement officials.

The case had unfolded fitfully over more than a decade. But it took a new police commissioner and his task force just six weeks to uncover a crucial clue in the sprawling case file.

Working under Commissioner Rodney K. Harrison, the core group of about 10 investigators was drawn from his department, the sheriff’s office, F.B.I. and State Police and worked closely with District Attorney Ray Tierney of Suffolk County and his prosecutors.

They worked in a beige office, its walls covered with maps, photos and a giant timeline, scouring their suspect’s digital and daily life — email addresses, social media accounts, search history.

All the while, Mr. Heuermann was searching, too, asking Google the same question that so many of his neighbors had been asking each other for more than a decade: “why hasn’t the long island serial killer been caught?”

Picking up the trail of a serial killer is an exceptional challenge. The killer often has no personal connection to the victims. If the victims lived on society’s margins, months or years can go by before their disappearances are treated as serious matters — or even recognized as the work of a single murderer.

The realization that a serial killer was hunting on Long Island’s South Shore came in December 2010, when a Suffolk County police officer, John Mallia, and his canine partner, a German shepherd named Blue, were searching for a 24-year-old woman named Shannan Gilbert, who had gone missing in the area.

Instead, over several days they found four other bodies near Gilgo Beach. They had been placed roughly 10 yards from Ocean Parkway, the main east-west thoroughfare that traverses a barrier island off the South Shore. After they discovered the bodies, investigators searched for evidence nearby with meticulous care — “sifting the sand like gold miners around each body,” one investigator recalled.

Ms. Gilbert’s corpse and other remains, including those that the authorities described as a man wearing women’s clothing and a toddler, would be found along the same roadway over the following year. The grisly discoveries riveted the region as the police speculated that the killings might be the work of more than one person.

But the first four bodies — all petite women in their 20s who had gone missing in the previous four years — seemed linked. Investigators surmised they had been killed by the same man, in part because of the way the bodies were wrapped and their proximity. And there was reason to believe that a witness might have gotten a look at the man.

The last of the four to disappear had been Amber Costello, a 27-year-old with a “Kaos” tattoo on her neck who advertised on Backpage and Craigslist. Shortly before she was last seen in September 2010, a would-be client contacted her from a disposable cellphone and visited her at the West Babylon house she shared with three roommates, parking in her driveway, according to court papers filed after Mr. Heuermann’s arrest. He drove a vehicle with a distinctive look: SUV in the front, pickup in the back.

The driver was just as distinctive: hulking, in his 40s, with bushy dark hair and 1970s-style eyeglasses. A witness described him as an ogre.

But as soon as the would-be client paid Ms. Costello, a chaotic scene unfolded. A man “pretending to be the outraged boyfriend” rushed in, part of a ruse to steal the money, according to the court papers.

Startled, the hulking man rushed out of the house.

He did not disappear for long, though. He texted Ms. Costello asking for “credit for next time” and arranged another meeting, according to the court papers. Ms. Costello was last seen alive the next night walking out of her home, apparently to meet the man.

Not long after, a witness reported seeing a dark truck drive by.

The description of the vehicle in the driveway, a dark, first-generation Chevrolet Avalanche, ended up tucked away in the case file, the authorities said.

The fact apparently lay buried for years among hundreds of thousands of pages of interviews; telephone, travel and credit records; and endless tips as the Suffolk County police department and district attorney’s office endured years of turmoil.

James Burke, the swaggering police chief who had been running the department since 2012, was arrested in 2015 and later convicted on federal civil rights and obstruction of justice charges. He had beaten a suspect who had been arrested after stealing cigars and a bag containing pornography and sex toys from Mr. Burke’s sport utility vehicle. The subsequent cover-up ensnared the district attorney at the time, Thomas J. Spota, who also landed in prison.

The federal investigation into Suffolk County’s top lawmen spanned years during the Gilgo Beach case, a period during which both Mr. Burke and Mr. Spota had spurned help from the F.B.I.

After Mr. Burke’s arrest, the new head of the Suffolk County police, Tim Sini, redoubled the department’s efforts. Mr. Sini, a former Manhattan federal prosecutor, focused on tracking the disposable cellphones, hoping there were more clues to be gleaned.

F.B.I. agents in 2012 had already identified the area where coverage from four cell towers overlapped in Massapequa Park. By mid-2016, Mr. Sini had secured a court order for “tower dumps” — information on every phone that connected to particular towers in a given window of time.

Technology and software had advanced. And Mr. Sini had invested in a system that allowed investigators to “take the relevant areas,” as he told Newsday, and “shrink them to extremely manageable spaces.”

They whittled down the area to what they came to call the polygon, which left them with several hundred homes around First Avenue in Massapequa Park, law enforcement officials said.

A pattern emerged from the disposable phones used to contact the victims: In the evening, nighttime and predawn hours, some were in a small area of Massapequa Park, a person with knowledge of the investigation said. That’s also where the phone of one victim, Megan Waterman, was last logged at 3:11 a.m. on June 6, 2010, shortly before she disappeared, according to court papers.

During the day, the phones were used in Midtown Manhattan.

Among other communications that investigators scrutinized were sadistic, taunting calls someone made from the cellphone of one victim, Melissa Barthelemy, to her teenage sister shortly after she had disappeared in 2009. “Do you think you’ll ever speak to her again?” the person had asked in a bland, calm voice.

Those calls were also linked to cell towers near Penn Station, the court papers said.

For years, investigators looked for suspects who worked in Manhattan and had lived in the polygon. The going was slow, and though investigators expressed optimism they would find their man, they had little to show.

The big break came in March 2022.

Just weeks after the formation of the task force, an investigator found the witness’s description of the Chevrolet Avalanche in the case file, authorities said. Using a database that can search for vehicles by make and model without license-plate numbers, the investigator found an Avalanche linked to Mr. Heuermann in 2010, the year Ms. Costello went missing.

His name had never come up in the investigation as a suspect, officials said. His physical description matched that of the ogreish man who had rushed out of her house shortly before she disappeared: He was 6-foot-4 and heavyset. His office was in the patch of Manhattan identified by the sophisticated cellphone mapping.

And he lived in what investigators believed was their serial killer sweet spot: the part of Massapequa Park where they had begun drawing their polygon.

The Avalanche lead, said Mr. Tierney, the district attorney, had been “known pretty much from the beginning.” Mr. Tierney, who took office in 2022, said he did not know why investigators had not pursued it. He suggested that perhaps the detail hadn’t been deemed credible or had sunk in significance amid what seemed like more promising leads.

“There are piles of evidence,” he said. “What is credible, what’s not, what seems likely, what’s not — so it’s not as simple as it seems.”

But crimes are often solved by tracking down a vehicle, and cases often start with a car description. David Berkowitz, known as Son of Sam and perhaps the state’s most notorious serial killer, was arrested in the 1970s after the police found that he owned an illegally parked Ford Galaxie that had received a parking ticket near one of the shootings.

In the Gilgo Beach investigation, the critical clue had fallen through the cracks.

“If they knew about it then, a major mistake was made in not tracking down this car earlier,” said Rob Trotta, a former Suffolk County detective and a current county legislator, who said he expects to make an official inquiry into what happened.

Dominick Varrone, the former chief of detectives who oversaw the first year of the investigation, questioned whether the Avalanche clue had actually been in the case file, but added, “I will feel very, very badly if our team missed something.”

“I’ll tell you right now: No suspect vehicle was on our radar when I was still there,” he added.

When investigators did finally link the Chevrolet Avalanche to Mr. Heuermann, the investigation entered its critical phase. Investigators began exploring every aspect of his life, using 300 subpoenas and search warrants.

They examined his Tinder account and several email addresses — all fictitious names — that led to additional disposable phones that Mr. Heuermann was using to contact massage parlors and women working as escorts, the court papers said. They found internet searches for child pornography.

The more investigators learned about Mr. Heuermann, the more convinced they were.

So much time had passed since the killings that precise locational data from Mr. Heuermann’s personal cellphone — registered to his architectural business — no longer existed. But his billing records showed the general location of the phone when calls were made, the court papers said, putting it in New York City around the same time in 2010 that the cruel and taunting calls were made on Ms. Barthelemy’s cellphone.

Investigators learned that several of the murders had occurred when Mr. Heuermann’s wife and children were out of town, according to prosecutors. One coincided with a trip his wife took to Iceland; another took place when she was in Maryland and a third when she was in New Jersey.

But they had nothing to put the burner phones that had been in contact with the victims in Mr. Heuermann’s hands.

Nor did they have any physical or forensic evidence directly linking him to the crimes.

That would soon change.

In the investigation’s early days, at least five hairs were discovered on the victims or stuck to the burlap or duct tape that enveloped them. They were deemed unsuitable for detailed DNA analysis.

Forensic science moved ahead: In the past three years, two outside laboratories were able to generate thorough DNA reports, according to court papers.

Now, investigators needed genetic material from Mr. Heuermann. Last July, an undercover detective rooted through his recycling for empty bottles. In January, Mr. Heuermann tossed a pizza box into a sidewalk garbage can outside his office in Midtown. A surveillance team fished it out, and the ragged crusts inside gave them what they needed.

Investigators concluded that most of the hairs found on the victims were likely to have come from Mr. Heuermann’s wife. One was a potential match for Mr. Heuermann himself.

One laboratory compared the DNA profile from the fifth hair to the genetic material found on Mr. Heuermann’s pizza. It found enough markers in common to conclude that while 99.96 percent of the population could be excluded as a match, Mr. Heuermann could not, the authorities said.

Mr. Tierney learned of the results in June.

He read the report again and again — perhaps dozens of times, as if trying to convince his brain of what his eyes were seeing.

Investigators believed they now had direct evidence linking Mr. Heuermann to the killings.

But investigators knew something else: Mr. Heuermann was scouring the internet for information about what they were doing.

Internet searches linked to his anonymous accounts included more than 200 queries in the past 16 months about serial killers generally and the investigation into the Gilgo Beach victims specifically. “Why could law enforcement not trace the calls made by the long island serial killer” was just one.

Mr. Tierney had grown increasingly worried that more victims would drop on his watch. He said that Mr. Heuermann had been visiting massage parlors — and contacting women working as escorts.

Mr. Tierney said he was sleeping badly, bedeviled by tension and worry. Last week, he decided the case had reached a tipping point.

So on the evening of July 13, detectives in suits and ties approached Mr. Heuermann after he walked out of his office building.

Mr. Heuermann, prosecutors said, had methodically covered his tracks and closely monitored the investigation.

But when the detectives arrested Mr. Heuermann after more than a dozen years of pursuit, Mr. Tierney said, his reaction was simple and instinctive: genuine surprise.