An escaped murderer was captured Wednesday after eluding hundreds of searchers for two weeks, a conclusion that brought relief to anxious residents of southeastern Pennsylvania who had endured sleepless nights as he hid in the woods, broke into suburban homes for food, changed his appearance, and fled under gunfire with a rifle pilfered from a garage, authorities said.

Danelo Souza Cavalcante’s heat signal was picked up around 1 a.m. from an aircraft, but storms prevented teams from continuing to track him until the morning, Pennsylvania State Police Lt. Col. George Bivens said. In the meantime, tactical teams secured the area, and later moved in with search dogs, Bivens said at a news conference.

“The were able to move in very quietly. They had the element of surprise. Cavalcante did not realize he was surrounded until that had occurred,” Bivens said.

Cavalcante — still armed with the rifle — tried to escape by crawling through thick underbrush, Bivens said, and he continued to resist as he was taken into custody after 8 a.m. He was bitten by a police dog and suffered a minor wound, he said.

State police had announced Cavalcante’s capture on social media earlier Wednesday, as the search entered its 14th day. Bivens said police will discuss new charges with county prosecutors.

Aerial footage from WPVI-TV news showed an armored vehicle with Cavalcante arriving at the Pennsylvania State Police barracks at Avondale. A handful of officers pulled from the back of the vehicle and quickly led him into the building. He was handcuffed and wrapped in what appeared to be a thermal blanket.

The end to the search for Cavalcante, 34, unfolded just beyond Philadelphia’s heavily populated suburbs, in an area of woods, rolling farmland and a county park. The search forced schools to close right at the start of the academic year, led to warnings for homeowners to lock their doors, and blocked roads over the busy Labor Day weekend.

Overnight into Wednesday, heavily armed law enforcement officers searched for the fugitive through downpours and thunder.

Cavalcante escaped from the Chester County jail in southeastern Pennsylvania on Aug. 31 by crab-walking up between two walls that were topped with razor wire, then jumping from the roof and dashing away. He had been awaiting transfer to state prison after being sentenced days earlier for fatally stabbing his girlfriend, and is wanted in connection with another killing in Brazil.

Authorities said over the weekend that Cavalcante had slipped out of the initial search area, shaved and changed his clothing, stole a vehicle to travel miles to seek aid from former co-workers in the northern part of the county, and then abandoned the vehicle, at least in part because it was low on fuel.

Authorities have declined to say how they think Cavalcante slipped out of the first search area, and officials have pushed back against questions about whether they blew a chance to catch him.

Then, late Monday, a motorist alerted police to a man matching Cavalcante’s description crouching in the darkness along a line of trees near a road in northern Chester County. Police found footprints and tracked them to the prison shoes identical to those Cavalcante had been wearing. A pair of work boots was reported stolen from a porch nearby.

State police said they believe he was looking for a place to hide when he saw an open garage. There, he stole a .22-caliber rifle and ammunition, and fled when the homeowner who was in the garage drew a pistol and shot at him several times, state police said.

“He didn’t, I believe, recognize that the owner was in there. And I think he was probably looking for a place to hide, ran for that garage, saw the firearm, grabbed that, encountered the homeowner and fled with the firearm,” Bivens said Tuesday.

That led hundreds of law enforcement personnel to search an area of about 8 to 10 square miles near South Coventry Township, roughly 30 miles northwest (50 kilometers) of Philadelphia.

Cavalcante’s escape was big news in Brazil, where prosecutors in Tocantins state say he is accused of “double qualified homicide” in the 2017 slaying of Válter Júnior Moreira dos Reis in the municipality of Figueiropolis, which authorities say was over a debt the victim owed him in connection with repair of a vehicle.

Pennsylvania authorities even broadcast a recording of Cavalcante’s mother speaking in Portuguese imploring him to surrender peacefully.

Cavalcante received a life sentence in Pennsylvania in August for killing his ex-girlfriend, Deborah Brandao, in front of her children in 2021. Prosecutors say he murdered her to stop her from telling police he was wanted in the Brazil killing. He had been arrested in Virginia after Brandao’s killing, and authorities say they believe he was trying to return to Brazil.

The prison tower guard on duty when Cavalcante escaped was fired. The escape went undetected for more than an hour until guards took a headcount.