AUGUSTA — A longtime patient at the state’s Riverview Psychiatric Center is accused of running amok last weekend, threatening to kill a hospital worker and a fellow patient and to disrupt a pending visit of licensing personnel.

Charles D. Miles, 35, faces charges of aggravated criminal mischief and terrorizing.

He is accused of doing $4,370 in damage to the hospital.

At his initial court appearance Friday via video from the Kennebec County jail, District Court Judge Eric Walker approved bail negotiated by attorneys that includes $5,000 cash with conditions that Miles not return to Riverview and that ban him from contact with five hospital employees.

Miles was originally committed to the custody of the Department of Health and Human Services in 1999 after being found not criminally responsible for burning down the Skowhegan Fairgrounds and causing millions of dollars in damage.

Capitol Police Sgt. Mark Brown said in an affidavit seeking his arrest that Miles threw an Xbox controller against the wall and used a cribbage board to break windows in a hallway, a scanner for the elevator, an exit sign and a globe.

He also slammed his head against windows, repeatedly saying, “I’m going to kill one of the staff here. They are not listening to me. They don’t think I’ll do it. I’m going to kill one of the staff here,” according to the affidavit filed Wednesday in Kennebec County Superior Court.

The episode is the latest in a series of problems at the state’s only forensic hospital over the past year.

It lost federal funding a year ago, and the hospital superintendent was replaced in March after a vicious attack by a patient on a mental health worker. That led to the hospital contracting for corrections officers armed with stun guns to watch patients deemed dangerous, and attracted the attention of federal regulators.

At the time Miles allegedly was committing the offenses Sunday, one Riverview employee said she heard him say, “I know how to really (expletive) people up and I plan on doing it when licensing is here next week.”

Miles also referred to a nurse who was struck last month by a chair, allegedly by another Riverview patient, saying that nurse did not deserve to be harmed but another employee does.

A witness statement referenced by Brown said Miles also threatened to continue to harm staff members and fellow patients and destroy property until he got to jail.

After Capitol Police took Miles to a separate room, he broke a glass cover over a light and threatened to use a broken piece of it to cut someone else, according to the affidavit.

The affidavit also includes a mental health evaluation of Miles’ outburst by Dr. Brendan Kirby, the hospital’s clinical director, who reviewed medical staff notes about the incident.

Kirby concluded that Miles’ behavior was “goal-directed and premeditated to meet his stated goals without evidence of psychotic or delirious symptoms that might compromise his capacity to appreciate the wrongfulness of his actions.”

Despite the finding of not criminally responsible for the Skowhegan Fairgrounds fire, Miles has been found guilty and sentenced to prison for escaping from the forensic unit of Riverview’s predecessor, the Augusta Mental Health Institute.

He also was sentenced to 96 months in federal prison for making threats against the president in the early 2000s related to his anger about a war.

He was back at Riverview in January 2013.

In March, Miles pleaded guilty to terrorizing Riverview staff members by threatening to kill a person there and to criminal mischief.

He was ordered to serve four months in jail.

District Attorney Maeghan Maloney said Friday: “The Legislature has to do something about the few people at Riverview that are preventing it from being a hospital.

“We need a separate location for people who can’t function in the environment. It’s not fair to the other people who can be helped.”

During the hearing from jail, Miles was represented by attorney Lisa Whittier. Attorney Hank Hainke was appointed to represent him in the criminal case.

The intent is to have Miles held in the special mental health unit at the Maine State Prison in Warren while the charges are pending.

“The situation at Riverview has gotten very serious,” Assistant District Attorney David Spencer told the judge in support of the arrangement. “The staff is afraid of this gentleman. The facility is at the point where it cannot operate with him there.”