They thought they had him cornered.

Danelo Cavalcante, facing life in prison for murder, had shimmied his way out of the Chester County jail on Aug. 31 and was on the run in exurbs of eastern Pennsylvania.

Local and state police set up a perimeter around the expanse where they suspected Mr. Cavalcante was hiding out. It might take a while, but they had him penned in, they thought.

Just before midnight the next day, Mr. Cavalcante broke into a house, apparently in search of provisions. He found a peach, an apple and some snap peas.

He also found himself steps from the man living there with his family, Ryan Drummond, who, hearing an intruder, had flicked the lights on and off, he said, only to see them flick on again and Mr. Cavalcante walk through the house before fleeing into the night.

Mr. Cavalcante was spotted at least twice over the next few days, still within the perimeter. The search, it seemed, was closing in.

Then, on Sept. 4, he was seen yet again, this time on a trail camera in a heavily wooded area near Longwood Gardens, a botanical garden spread over almost 1,100 acres.

The camera, authorities realized, was outside the search perimeter, which meant Mr. Cavalcante was, too.

It wouldn’t be the last time Mr. Cavalcante, 34, dodged the dragnet, which drew hundreds of law enforcement officers, spread fear through Chester County’s small towns and captured the nation’s attention for 13 days.

Convicted of killing an ex-girlfriend in Chester County in April 2021 and sought in a 2017 killing in his native Brazil, Mr. Cavalcante was desperate, authorities said — and resourceful, which enabled him to stay ahead of his pursuers, sometimes by just steps, sometimes by miles. For days, he crept through Chester County’s leafy communities, dotted with farms, thick woods and cul-de-sacs, about an hour from Philadelphia.

Shortly after escaping, he pilfered a backpack from a home near the jail. Inside the bag, he found a razor, which he used to shave his beard in an attempt to make himself less recognizable.

Just five feet tall and 120 pounds, he did his best to lay low as he traversed the woods of Chester County, hoping to flee the region and make his way to Canada or Puerto Rico, authorities said.

“He moved only at night, slept during the day and used the tree line” to plan his movements, Robert Clark, a supervisory deputy U.S. marshal, said in an interview.

After the authorities learned that Mr. Cavalcante was seen on a trail camera on Sept. 4, they shifted the search area south. But as the police scoured that area, Mr. Cavalcante spotted two unlocked vehicles — and opted for the newer one, a white 2020 Ford transit van with the keys inside.

It had only about a quarter tank of gas, Mr. Clark said, but Mr. Cavalcante used it to drive north, where he tried to reach former co-workers at their homes. At one, he was captured on a doorbell camera, by then cleanshaven and in a hoodie.

All the while, the manhunt was growing, with hundreds of local, federal and state officers, backed by dogs and aircraft.

At one point, he went three days without food, and as the search wore on, he considered surrendering, Mr. Clark said. “It was difficult to live out there.”

Instead, he kept moving, and kept breaking into houses, Mr. Clark said.

As Mr. Cavalcante moved through the woods, he took steps to mask his tracks, sometimes covering his excrement with leaves so as not to be tailed, Mr. Clark said. He stayed hydrated by drinking from a stream. At one point, he found a watermelon on a farm and split it open by smashing it with his head.

“Desperate people do desperate things,” said Lenny DePaul, former commander of the United States Marshals Service fugitive task force for New York and New Jersey.

The police found the van last Sunday, in a field behind a barn. The next night, a tip from someone driving in the area led the authorities to footprints in the mud that matched the pattern of Mr. Cavalcante’s jail-issued shoes.

Perhaps realizing that he was leaving a trail, he ditched the shoes for a pair of work boots he stole from the porch of a nearby home.

He apparently decided he might need more than different shoes.

That night, Mr. Cavalcante came upon an open garage in South Coventry Township and spotted a rifle leaning in a corner. He grabbed it, but not before he was spotted by the homeowner, who fired several shots with a pistol. Mr. Cavalcante wasn’t hit and disappeared into the night again.

Word that Mr. Cavalcante was armed set off alarms across the county and raised the stakes of the manhunt.

Then came a crucial break.

At about 1 a.m. on Wednesday, in an area of farms and forests west of a state highway, a Drug Enforcement Administration plane that was assisting in the search picked up a heat signal suggesting that someone was nearby, according to Lt. Col. George Bivens of the Pennsylvania State Police.

An ill-timed storm forced the plane out of the area, delaying the search. But it resumed hours later, and around 8 a.m., officers moved in. Mr. Cavalcante was caught by surprise in a patch of woods in Pottstown, behind a John Deere store.

Wearing a Philadelphia Eagles sweatshirt he had stolen during his time on the lam, he tried to crawl away, his rifle in tow.

But a dog from the Border Patrol, which was assisting in the search, was sent after Mr. Cavalcante. The 4-year-old Belgian Malinois named Yoda caught him, leaving what officials called a “minor bite wound.” Soon, Mr. Cavalcante was handcuffed and in custody.

Mr. Clark said that when Mr. Cavalcante was interviewed by investigators, he told them that he knew he had to pay for what he did but didn’t want to pay with his life.

Hours after his capture, Mr. Cavalcante was transported to the maximum-security state prison in Collegeville, Pa., where he began serving a life sentence.

About 30 miles south, back in Chester County, Mr. Drummond, who lives with his wife and three children, hasn’t been able to shake the fear stirred by the manhunt that played out in his neighborhood — and in his kitchen.

Nearly every night since his encounter with Mr. Cavalcante, Mr. Drummond said, he could have sworn he heard a noise or saw a light flash in his kitchen. “The paranoia is there.”

Even the night after Mr. Cavalcante was caught, Mr. Drummond stood on the upstairs landing with a bat in his hand, listening for any movement.