(Reuters) - A divided Mississippi Supreme Court ruled on Thursday that some local judges acted unconstitutionally by banning people with enhanced concealed-carry licenses from taking guns into their courthouses.

The court said judges of the 14th Chancery District, which includes six counties in eastern central Mississippi, exceeded their authority under the state constitution because only the legislature could regulate or forbid the carrying of concealed weapons.

“The orders at issue usurp that power,” Justice Michael Randolph wrote for a five-justice Supreme Court majority. “No matter how well-intentioned, judges are without power to limit enhanced concealed-carry licensees’ rights to carry a firearm beyond courtrooms in the State of Mississippi.”

A 2011 law allowed people with enhanced concealed-carry licenses to take firearms into Mississippi state courthouses, though judges could ban the weapons from courtrooms.

Ricky Ward, a firearms instructor, had challenged the broader ban in the 14th Chancery District. He appealed after its judges noted that the district’s courthouses “were all built many years ago and not designed to properly secure courtrooms.”

Randolph said the judges’ concerns were “well-founded,” but that “their personal fears and opinions do not trump, and cannot negate, constitutional guarantees.”

Two dissenting justices from Thursday’s decision found the broader ban constitutional. Two other justices partially dissented, saying the ban appeared overbroad but that a narrower version might pass muster.

“The fundamental issue is not about firearms, but the rule of law,” Ward’s lawyer Thomas Payne said in an interview. “The judges had good intentions about the importance of security in their courtrooms but cannot unilaterally make judgments that are against the constitution or law of the State of Mississippi.”

The judges in the Chancery District did not immediately respond to requests for comment.

The case is Ward v Colom, Supreme Court of Mississippi, No. 2016-M-01072-SCT.