The hunt was a frustrating game of cat and mouse for the police, who were searching for him in the thick woods of the Pocono Mountains. The police and residents caught glimpses of Mr. Frein in the woods, but officers were unable to get close.

State officials held a series of news conferences at which they offered assurances that Mr. Frein’s capture was imminent. Throughout, officials also tried to assure residents that Mr. Frein had a hatred of law enforcement and wanted to target police officers, not the general public.

“Some of the sightings have occurred in circumstances where he kept himself far enough away, where he knew that it was unlikely that someone could get to him,” Lt. Col. George Bivens of the state police said at one of his weekly updates on the manhunt. As the search dragged on, deer hunting was called off for that region of Pennsylvania. Officials in Barrett Township canceled trick-or-treating on Friday and the 50th annual Halloween parade.

Cheri Jones, an organizer on the Barrett Township Halloween Committee, lives on a farm next to an elementary school whose grounds police have used to send helicopters over the woods to aid in the search for Mr. Frein. She said his capture brought her a sense of relief and hope for a night of sleep uninterrupted by the sound of helicopters.

“Finally, it’s over,” she said. “It looks like the town is ready to have a big celebration.”

Colonel Bivens told reporters in September that a search of a computer used by Mr. Frein found indications that he had been planning the attack for some time, and that he had looked into how to evade police manhunts. Mr. Frein also experimented with explosives, Colonel Bivens said, and officers searching the woods have kept a watch for booby-traps.

“I suspect he wants to have a fight with the state police, but I think that involves hiding and running, since that seems to be the way he operates,” Colonel Bivens said, according to The Associated Press. “I expect that he’ll be hiding and try to take a shot from some distance from a place of concealment, as he has done in the past.”

During the manhunt, the police seized supplies of food, including tuna fish and instant noodles, as well as 90 rounds from a rifle of the same type used in the ambush. Colonel Bivens told reporters that the police believed Mr. Frein had been searching trash cans at cabins, groceries and restaurants, looking for food.