The Florida state Supreme Court said Monday that Gov. Rick Scott (R) will not be allowed to appoint three new justices to the court on the morning he steps down as governor, after voting rights groups sued him over his plans to replace the three judges whose terms will come to an end at midnight before Scott’s successor is sworn in.

“The governor who is elected in the November 2018 general election has the sole authority to fill the vacancies that will be created by the mandatory retirement of Justices Barbara J. Pariente, R. Fred Lewis, and Peggy A. Quince,” the state Supreme Court said, “provided the justices do not leave prior to the expiration of their terms at midnight between January 7 and January 8, 2019, and provided that the governor takes office immediately upon the beginning of his term.”

The retiring justices, who are stepping down due to mandatory age limits, are all left-leaning, according to Slate. In attempting a power grab that would have let him lock in a right-leaning majority for years regardless the winner of the 2018 governor’s race, Scott was trying to exploit a loophole in that their terms expired at midnight, January 8, but his successor wouldn’t be sworn in until that day, usually at around noon.

“I will appoint three more justices on the morning I finish my term,” Scott said last year.

Those plans attracted a lawsuit from the Florida League of Women Voters and Common Cause, which said that Scott’s attempts to “make appointments to shape the judiciary on his way out of office would run directly contrary to the core principle of this State that political power is inherent in the people.”

Scott is currently running for the U.S. Senate. The race to replace him — between Democratic Tallahassee Mayor Andrew Gillum and Republican U.S. Rep. Ron DeSantis — is close, according to polls.