0 of 0

Updated at 7:40 p.m. ET

David Sweat, one of two inmates who escaped from a prison in upstate New York earlier this month, has been shot but taken alive just days after his accomplice, Richard Matt, was killed by police.

After three weeks on the run, Sweat was captured Sunday afternoon near the town of Constable, N.Y., about a mile and a half from the Canadian border. The capture came after a confrontation with a police sergeant who saw the escapee walking along the side of the road.

Speaking at a press conference Sunday evening, New York State Police Superintendent Joseph D'Amico said that Sgt. Jay Cook first ordered Sweat to stop, but that Sweat then tried to flee on foot.

"At some point, running across a field, he realized that Sweat was going to make it to a tree line and possibly could have disappeared," D'Amico said, "and [Cook] fired two shots from his service weapon, his handgun."

The shots hit the unarmed escapee in the torso, according to authorities. D'Amico said that Cook had been alone on a routine patrol at the time of the confrontation.

"The nightmare is finally over," said New York Gov. Andrew Cuomo, speaking at the same press conference. Cuomo lauded the efforts of law enforcement, adding: "Today ends with good news. These were really dangerous, dangerous men."

On June 6, Matt, 49, and Sweat, 35, used power tools and tunneled through a wall in their cell, climbed a catwalk, crawled through a steam pipe and emerged on the outside of the Clinton Correctional Facility in Dannemora, N.Y., in an extraordinary escape. It later emerged that the pair also had inside help.

The hunt for the escaped convicts involved hundreds of local, state and federal officials who scoured dense forests dotted with hunting cabins, where the pair apparently sought shelter while on the run.

Matt was shot and killed near Malone, N.Y., on Friday after officials say he was "verbally challenged" but failed to put up his hands as ordered.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.