A man who escaped a Rhode Island maximum security prison has been captured in Somerville, state police confirmed.

Police spotted the convict walking the streets and he was taken into custody on Wheatland Street near Foss Park shortly before 4 p.m., WHDH reported.

James Morales, a former Army reservist, escaped from the Wyatt Correctional Center in Central Falls, Rhode Island, on New Year’s Eve, by climbing up a basketball hoop and crawling through razor wire, state police said. He then made his way to Massachusetts.

RELATED: Escaped inmate continues to evade police in Massachusetts

Police were tipped off to Morales' whereabouts Thursday morning after a man matching his description attempted to rob a Bank of America on Massachusetts Avenue in Cambridge.

RELATED: Cambridge bank robbery causes Red Line delays Thursday morning

Morales may have tried to rob a second bank in Somerville.

Morales, 35, was in prison on charges that he stole 16 guns from a federal armory in Worcester in 2015.