© Ian Thomas Jansen-Lonnquist for The New York Times New York State Police at a roadblock in Malone, N.Y., on Sunday.

CONSTABLE, N.Y. — David Sweat, the remaining prison escapee on the run in northern New York, was shot by a state trooper and taken into custody on Sunday after a 23-day manhunt that began with an improbable escape from two maximum-security cells and ended in the rain-drenched woods just south of the Canadian border.



Mr. Sweat, 35, a murderer who had been serving a sentence of life without parole, was in stable condition, said Gov. Andrew M. Cuomo, who spoke late Sunday surrounded by law enforcement officers at a news conference marked by cheers and applause.

The shooting occurred in this town around 3:20 p.m. after a State Police sergeant spotted a man jogging down a road, stopped to question him and recognized him as Mr. Sweat, said Superintendent Joseph A. D’Amico of the New York State Police. He told Mr. Sweat to come over to him, but instead Mr. Sweat turned and fled across a field toward the tree line, Mr. D’Amico said. Sergeant Jay Cook, a firearms instructor who was patrolling by himself, gave chase and finally opened fire, striking Mr. Sweat twice in the torso, because he realized the fugitive was going to make it to the woods, Mr. D’Amico said, and possibly disappear.

More than 1,300 officers in rain-slicked gear had helped to tighten a cordon around Mr. Sweat on Sunday as the search, which had at times appeared to lurch between small New York towns as officials chased shreds of reported sightings, focused in on 22 square miles of rugged terrain. The confrontation with Mr. Sweat took place two days after his partner in flight from the authorities, Richard W. Matt, was shot and killed by a federal agent in the woods of Malone, N.Y.

“The nightmare is finally over,” Mr. Cuomo said. “These were really dangerous, dangerous men.”

Mr. Sweat, who was spotted and captured within a few miles from the Canadian border, was unarmed and wearing mudstained and dark-colored clothes. He was taken to Alice Hyde Medical Center on Sunday and was being moved to Albany Medical Center for further treatment, Mr. D’Amico said.

Word of the manhunt’s end brought relief across this bucolic region, which had been in a near-constant state of alert as residents locked doors once left unsecured and cast a wary eye on every pair of men.

Denise Yando, who lives on a 30-acre property on Coveytown Road in Constable, said state troopers came to her home to say that Mr. Sweat had been shot in a nearby field. “I suspected they would come toward Canada,” Ms. Yando said. “Every time I walk the dog, I’m always looking down the tracks. But I didn’t think it would happen in the field.”

The final days of the search hewed closely to what had been, from the start, a Hollywood-style drama of ingenuity, flight and violence. The escape by Mr. Matt and Mr. Sweat from the Clinton Correctional Facility, discovered on June 6, involved long-term planning, subterfuge and trickery as the men cajoled favors and privileges from prison employees using flattery and, in Mr. Matt’s case, a talent for painting. Their flight lasted longer than some law enforcement observers had expected, but the two convicted murders appeared to have never made it more than a few dozen miles from their starting point: a manhole on a street in Dannemora, N.Y., mere steps from the high prison walls meant to contain them.

After a civilian prison employee, Joyce E. Mitchell, failed to meet them in her car, the two men, who displayed cunning inside the prison walls, were forced to run on foot over tough terrain. They found shelter in empty hunting cabins, but left telltale clues of their presence that helped a vast array of agencies — from the State Police to the United States Marshals to the Federal Bureau of Investigation to state Forest Rangers — hone in on them over the last week.

It was not clear whether the men remained together the whole time, but they appeared to have been together recently enough that a discarded pepper shaker bearing Mr. Sweat’s DNA was found by investigators over the weekend not far from the spot where Mr. Matt was killed on Friday.

Mr. D’Amico, of the State Police, said the men possibly used the pepper to throw off the scent of the search dogs, a ruse employed in the 1967 film “Cool Hand Luke.”

“We did have difficulty tracking, so it was fairly effective in that respect,” he said.

“If you were writing a movie plot, they would say that this was overdone,” said Mr. Cuomo, speaking at a ski resort in Malone that has doubled as a command center.

Earlier Sunday, the State Police said the search had been continuing “around the clock” and despite a pelting rain that prompted the National Weather Service to issue a flood watch for the area. The swell of law enforcement in the region, bolstered with the additional 100 officers announced on Sunday, allowed the authorities to have a regular rotation, swapping out fatigued searchers. That continued pressure may have helped wear down the two men. An autopsy of Mr. Matt showed blisters on his feet, according to a statement from the State Police, as well as “minor abrasions consistent with living in the woods for three weeks.”

With dense vegetation and rolling terrain, the woods here had been made even more difficult to navigate, as searchers had to make their way through fog, heavy downpours of rains and the boot-soaking slush left behind.

The two men were both convicted murderers, with Mr. Matt serving a sentence of 25 years to life after being convicted in 2008 of murdering an dismembering a former boss. (Before his trial, he served nine years in a Mexican prison for fatally stabbing an American engineer in a bar bathroom in Matamoros in 1998.)

Mr. Sweat had been serving a sentence of life without parole for the July 4, 2002, killing of a Broome County sheriff’s deputy, Kevin J. Tarsia, after he came upon Mr. Sweat and two friends dividing up the spoils after robbing a fireworks and firearms store in Pennsylvania. Mr. Sweat shot him multiple times. While Mr. Tarsia was still alive, Mr. Sweat ran over him in his car.

His escape from Clinton Correctional Facility was not the first hint of Mr. Sweat’s penchant for steeping himself in plans requiring knowledge of architecture and engineering to help him commit a crime. In 1996, Mr. Sweat, then 16, and another teenager tried to steal a computer and cash from a group home in Binghamton where he was staying. Their plan depended in part on obtaining blueprints and a layout of the home.

After later being convicted of second-degree burglary in a separate incident, Mr. Sweat was found to be keeping a list of his future crimes in his prison cell.

Sunday’s confrontation with Mr. Sweat came two days after and roughly 15 miles north of the spot near Lake Titus where an agent from a tactical unit of the United States Border and Customs Protection agency shot Mr. Matt three times in the head, according to the autopsy. The agent, who was not named, opened fire after Mr. Matt, armed with a 20-gauge shotgun, did not put up his hands when ordered to do so.

On Sunday afternoon, Mike Doyle, 41, who lives on Coveytown Road, said he heard two gunshots and then saw “troopers running down the road with their weapons out.” Dozens of cars, lights flashing, raced by his home, followed by units from Customs and Border Protection and the United States Marshals Service.

He saw an ambulance drive onto a hayfield across the street from his home and then take off, apparently carrying Mr. Sweat. “It was very, very overwhelming when it all started,” he said. “And now it’s just a sigh of relief, just to know he was this close to the home and they got him.”

With the capture of Mr. Sweat alive, officials hoped to learn more about how exactly he and Mr. Matt managed to mount their escape and their route once on the outside. In addition to Ms. Mitchell, the authorities also arrested a corrections officer, Gene Palmer, who is accused of giving the men pliers and a screwdriver in exchange for paintings by Mr. Matt.

For residents of Dannemora and other towns of Northern New York, the capture of Mr. Sweat brought a chance to finally relax after weeks of worrying about what lurked in the untrammeled woods. Stores offered free coffee to searches and exclamations of joy at the capture.

“I haven’t opened my window in three weeks!” said Amber Hammond, 27, who has lived in Constable her entire life.

Leslie Lewis, 29, who encountered the two escapees in his backyard just after they escaped three weeks ago, said the first thing he was going to do now that they had been taken care of was go for a hike and build a fire in the woods, a favorite pastime. “We haven’t been able to do that in a while,” he said.