A man accused of trying to break into a cab barricaded himself in a Pinellas County motel room for several hours Tuesday morning.

The Pinellas County Sheriff's Office sent out a SWAT team to ultimately get the 23-year-old man out of the room and into custody.

According to deputies, David Shaffer was staying at the America's Best Value Inn Motel in the 28000 block of U.S. 19 in Clearwater with his girlfriend. Officials said at some point early Tuesday, Shaffer left the motel room and went to a nearby Mini Storage facility, where he broke into a taxi cab.

The driver of the cab, Robert Stipins, 34, called the sheriff's office after seeing a man break into his cab and take his backpack.

Officials said when Stipins approached Shaffer, the younger man said he had a gun and would shoot Stipins, who then backed off. He later followed Shaffer and advised deputies.

When deputies responded to the motel, Shaffer made more threats and refused to come out, officials said. A SWAT team was called in and officials began negotiating with him.

Officials said after about three hours, Shaffer exited the room peacefully. He has been charged with armed burglary.

An investigation is ongoing.