Police shot and wounded a defendant outside a courthouse Tuesday after he escaped from authorities and stole a car from a nearby parking lot.

A defense attorney said Anthony Roberts, 22, of Cambridge crashed into several parked cars and then was surrounded by police when he was shot outside Barnstable District Court, where he was scheduled for arraignment.

"Law enforcement was trying to apprehend him, at which time a Barnstable officer shot him," said the man's attorney, J. Drew Segadelli.

Fire Chief Robert Crosby said the man was shot in the chest, and a hospital spokesman said he was in critical condition at Beth Israel Deaconess Medical Center in Boston.

Richard Ruggiero, a driver for the Cape Cod Times newspaper, said he was nearby when police yelled at him to help block the suspect in the stolen vehicle.

The suspect hit Ruggiero's van before he sped across a street and struck a stone wall in front of the courthouse complex.

"One shot was fired by one of the officers because he was trying to get away," Ruggiero said.

Roberts had been arrested Friday after he left the scene of an accident in which he allegedly struck a tree, Segadelli said. He said police also charged him with receiving stolen property — a plasma television — and suspected him in a series of recent break-ins of cars and homes on Cape Cod.