North Carolina’s highest court on Friday upheld a law subjecting the governor’s choices to run his top agencies to confirmation votes by the state Senate, providing a legal victory to Republican legislators.

The state Supreme Court ruled unanimously in favor of GOP legislative leaders who passed the confirmation requirement for Cabinet secretaries just before Democratic Gov. Roy Cooper took office in early 2017.

Cooper sued over the new process, calling it unconstitutional. The law was among several changes approved in an extraordinary December 2016 session that eroded or checked powers of Cooper, who had just narrowly defeated then-GOP Gov. Pat McCrory.

Lower courts sided with GOP lawmakers on their right to reject the governor’s appointments to run at least 10 Cabinet-level agencies, with responsibilities ranging from paving roads and collecting taxes to securing prisoners.

Writing for the court Friday, Chief Justice Mark Martin said the confirmation requirement doesn’t violate the constitutional principle of separating the powers and duties of the executive and legislative branches.

“The governor has unfettered power to nominate any eligible individual to serve in his Cabinet, has significant supervisory power over his Cabinet members, and has the power to remove Cabinet members at will,” Martin wrote. “The constitution, moreover, does not otherwise prohibit the General Assembly from requiring senatorial confirmation of members of the governor’s Cabinet.”

The state constitution says the governor “shall nominate and by and with the advice and consent of a majority of the senators appoint all officers whose appointments are not otherwise provided for.” It provided the basis for the law requiring Cabinet approval, which was enforced during the litigation. After some parliamentary fighting over secretaries making committee appearances, all of Cooper’s nominees were confirmed in Senate votes in 2017.

The governor’s choices to the state Utilities Commission, Industrial Commission and Board of Education already are subject to legislative confirmation.

In October, Cooper’s lawyers argued before the justices that although the General Assembly has the power to shape the duties of Cabinet-level agencies, it can’t interfere with how the governor carries out those duties or whom he hires to help him.

There were no dissenting opinions among the seven-member court. Four of the seven justices are registered Democrats.

Martin, a registered Republican, wrote that Cabinet confirmation differed from recent court rulings in which a majority of justices decided the legislature had gone too far in choosing at least half of the members of certain state boards and commissions. That included recent iterations of the state elections board, one version of which was approved in the December 2016 session.

Spokesmen for GOP legislative leaders and Cooper contacted Friday didn’t immediately comment on the ruling.

Otherwise, Cooper has had some success going to court to turn back laws approved in the 2016 session. In addition to blocking new compositions of the election board, he recently got trial court judges to rule that the legislature went too far in giving McCrory decision-making over who leads the Industrial Commission — which handles workers’ compensation cases — through Cooper’s entire four-year term.