RALEIGH, N.C. (AP) – A federal judge has approved a legal settlement allowing transgender people to use restrooms matching their gender identity in many North Carolina public restrooms.

The consent decree approved Tuesday by a federal judge could end a protracted lawsuit by transgender people against North Carolina’s so-called bathroom bill and the law that replaced it.

The agreement between the plaintiffs and North Carolina’s Democratic Gov. Roy Cooper says that nothing in state law can be interpreted to “prevent transgender people from lawfully using public facilities in accordance with their gender identity” in buildings controlled by the state’s executive branch.

In return, plaintiffs have agreed to drop pending legal action against the governor and other defendants.

North Carolina’s Republican legislative leaders had opposed the agreement.

(Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)