DES MOINES, Iowa — The Iowa Supreme Court on Tuesday banned weapons in courthouses statewide, saying that it had a duty to promote safety in the courts.

The order signed by Chief Justice Mark Cady does not apply to peace officers but it prohibits other visitors from carrying weapons into courthouses in all 99 counties.

Currently 72 counties prohibit weapons in the courthouse by county ordinance or order of the chief judge in the judicial district. The court says 27 counties have no known courthouse prohibition on weapons. Ten counties have airportlike metal detectors at entrances.

Cady said current policies have failed to provide uniform protection across the state.

“This policy serves to establish a safety perimeter for each courthouse or justice center that allows for the efficient implementation and enforcement of a weapons prohibition and is intended to prohibit the general public from entering any courthouse or justice center with a weapon,” Cady wrote.

The order requires the chief judge in each judicial district to work with local officials to carry out the order but does not specify any one solution.

Bill Peterson, the executive director of the Iowa State Association of Counties, said many counties that ban weapons but have no formal inspection upon entering the courthouse. In most cases public notices are posted declaring the building off limits for weapons and violators could face charges if caught.

“Sometimes emotions run high and emotions and weapons sometimes lead to consequences nobody ever thinks will happen but somehow do,” he said.

In September 2014, a 71-year-old man became upset at his home’s tax assessment and took a gun from a briefcase and shot at the county assessor during a meeting at the Jackson County Courthouse; he missed. He was shot and killed when the gun went off as several other people in the meeting wrestled him to the floor.

In March 2014, a man unhappy with his 10-year sentence for a drug conviction pulled a gun from his pants at the Madison County Courthouse and fled from sheriff’s deputies. He was soon caught.

Peterson said the court’s action also may be in response to a bill signed into law by Gov. Terry Branstad in April. Touted by supporters as a sweeping victory for Second Amendment rights, the bill allows concealed weapons to be carried into and around the Iowa Capitol by anyone with a gun permit.

It also includes a paragraph that says anyone adversely effected by a local “ordinance, measure, enactment, rule, resolution, motion or policy” may sue for damages if their gun rights are usurped.

That appears to be contrary to a 2003 opinion from the attorney general that Iowa cities and counties may pass weapons restrictions for the property they own.

Iowa Firearms Coalition Executive Director Barry Snell condemned the court order as judicial overreach which may require the Iowa legislature to act.

He said the court’s jurisdiction to control guns does not go beyond the courtroom, judge’s chambers or other court-related spaces.

In most Iowa counties, courthouses include county offices that handle driver’s licenses, property taxes and other local government functions.

“If the chief justice’s position is they’re able to enact a no-guns-allowed policy across the entire building, then that’s a potential instance of judicial overreach,” he said.

The Iowa State Bar Association, a professional group representing about 8,000 lawyers, supported the court’s action.

“We must be proactive to protect public safety, prevent a tragedy from occurring and ensure that justice can be attained in an environment that is safe,” said Skip Kenyon, the group’s president.

Cady’s order says the Iowa Constitution vests the Iowa Supreme Court with the power to exercise supervisory and administrative control over the district courts as justification for the order.

“Courthouse security is inseparable from the concept of justice itself,” he said.