A 29-year-old man was arrested early Thursday morning after a lengthy standoff in Colorado Springs.

Police arrested James Ferrell, who was wanted for felony burglary and trespassing charges.

Police tried to contact Ferrell at an apartment in the 1800 block of Monterey Road around 6 p.m. Wednesday. Ferrell refused to leave the apartment and barricaded himself in a bedroom, police said.

Ferrell then tried to escape officers by crawling through an attic space as people were being evacuated, police said.

Police said they used several chemical agents while trying to persuade Ferrell to leave the apartment.

Finally, around 1 a.m. Thursday, Ferrell left the attic and was taken into custody.

Ferrell is charged with four additional trespassing charges and a violation of a protection order.