-- A Massachusetts state trooper spotted a federal prison escapee in a town outside Boston and chased him on foot for two blocks before taking the man into custody as he tried to jump a fence.
James Morales, 35, had been on the run for days after breaking out of a federal prison in Rhode Island on New Year's Eve.
On Thursday afternoon, after Morales allegedly tried to rob two banks in the Boston area, state trooper Joseph Merrick chased and captured him in Somerville, Massachusetts.
"At the beginning of the shift, we were notified that the subject might be in the area," Merrick later said at a news conference.
"I saw the suspect, which I believed to be the escapee from Rhode Island," Merrick said. "After a foot chase, a couple fences, I was able to get him into custody."
A few other officers helped Merrick make the arrest, Merrick said.
"It was a great job by everybody just to get him off the street, a dangerous man," Merrick told reporters. "I was glad I could help out."
Morales -- a former Army reservist -- was in federal custody for the "theft of numerous firearms from the Worcester Army Reserve Armory in 2015," Massachusetts State Police said. He was also wanted "for an alleged violent and brutal sexual assault of a child," police said.
He escaped from a Rhode Island federal prison -- the Donald W. Wyatt Detention Facility in Central Falls -- on New Year's Eve, authorities said.
Morales made an initial appearance in federal court in Providence, Rhode Island, this morning on a criminal complaint filed Jan. 1, charging him with escape from custody.
He appeared in the courtroom wearing shackles and handcuffs and was ordered returned to custody, ABC affiliate WCVB in Boston reported.
Officials said Morales broke out of the Wyatt detention facility by climbing a basketball hoop to reach a rooftop, cutting through a fence and then climbing through razor wire.
He was found to be missing by prison staff at 10 p.m. on Dec. 31 -- about three hours after he escaped, authorities said.
Jamie Hainsworth, a U.S. marshal for the district of Rhode Island, said earlier this week that officials will take a "hard look" at the procedures of the Wyatt prison and investigate whether the community of Central Falls was appropriately notified of the escape.
Hours before his capture, Morales allegedly tried to rob one bank in Somerville and another in nearby Cambridge, Massachusetts.
Morales will not be taken back to the Wyatt facility, U.S. Marshal Kevin Neal told reporters.
ABC News' Michele McPhee contributed to this report.