ROCKLAND — A 62-year-old Bangor man who police say created a nearly five-hour standoff at a downtown hotel had stopped in Rockland on his way home from a jail stay.

Timothy N. St. Thomas was arrested shortly before 1 p.m. Sunday at the Trade Winds Inn and charged with criminal threatening with a dangerous weapon, two counts of disorderly conduct and criminal trespass.

He was taken to the Knox County Jail in Rockland. On Monday afternoon, District Court Deputy Chief Judge Susan Sparaco set bail at $5,000 cash during a hearing at Knox County Unified Court in Rockland.

Assistant District Attorney Christopher Fernald said St. Thomas has a lengthy criminal record dating back to 1981, including convictions for numerous criminal trespass, assault and threatening offenses. Fernald said St. Thomas had completed a jail sentence Thursday at Two Bridges Regional Jail in Wiscasset and was heading to Bangor when he stopped for a stay at the Trade Winds.

According to a court affidavit filed by police, Rockland officers were called to the hotel before 8 a.m. Sunday by the hotel staff, who asked for St. Thomas to be removed.

St. Thomas was screaming in his room when officers arrived. They asked him to come out but he refused and began barricading the door with items inside the room, according to the affidavit.

Officers got a room key, pushed the door open and were met with St. Thomas threatening to kill them and swinging a 4-to-5-foot-long stick at their heads.

Police retreated and the standoff began. There were no injuries.

Officers were initially called to the hotel at 4:30 a.m. when St. Thomas was being disorderly, according to police, but they managed to calm him down.

The chief said Sunday since officers did not know if he had any other weapons in the room, they decided to hold off trying to immediately enter the room.

The section of the hotel on the fourth floor was cleared, but otherwise guests remained in their rooms. People were coming out of the hotel throughout the standoff, getting in their vehicles and leaving.

A Maine State Police tactical team tried to talk with St. Thomas, but except for once when he came out onto the balcony of his room, he did not communicate with them. On the balcony, he was ranting about a variety of things and saying he was a veteran and wanted more respect. He also said that all he wanted earlier in the morning was food and the dining area was not open, so he got the food himself.

Local attorney William Pagnano, who is also a justice of the peace, signed a search warrant and arrest warrant for police before they entered the room to apprehend St. Thomas.

The Trade Winds is on Park Drive across from the Rockland police station. Harbor Park was closed off as police vehicles staged in back of the station and out of view of the hotel room where St. Thomas was. Park Drive from Main to Winter street was also closed shortly before state police went inside the room.

At Monday’s hearing, defense attorney for the day Daniel Purdy said that St. Thomas had been in court two weeks earlier and another judge said he was not mentally fit to be in court.

St. Thomas asked to have an attorney appointed for him.