The Supreme Court ruled unanimously on Monday that states have the authority to require members of the Electoral College to vote for the candidate they had pledged to support.

“The Constitution’s text and the nation’s history both support allowing a state to enforce an elector’s pledge to support his party’s nominee — and the state voters’ choice — for president,” Justice Elena Kagan wrote in the majority opinion.

Laws requiring electors to vote as they had promised exist in 32 states and the District of Columbia, but recent court decisions have questioned whether the state is able to enforce electors sticking to their pledges.

Electors in states without such law may choose to disregard their original pledge.

The court granted review of a pair of cases concerning Washington State and Colorado in January and were expedited to be decided prior to the presidential election.

Although no election has been swung by the votes of electors going against their pledge, the issue gained traction during the 2016 election in which seven electors nationwide voted against their initial pledge.

Last year, the Washington State Supreme Court upheld fines of $1,000 on three Democratic electors who voted for former National Security Adviser Colin Powell instead of former Democratic nominee Hillary Clinton.

“The three hoped they could encourage other electors — particularly those from states Donald Trump had carried — to follow their example,” Kagan wrote. “The idea was to deprive him of a majority of electoral votes and throw the election into the House of Representatives.”

Shortly after the Washington Supreme Court ruled that states may require electors to vote for their parties’ candidates, the United States Court of Appeals for the 10th Circuit in Denver decided the opposite, ruling that Colorado had been wrong to throw out a vote from a Democratic elector who attempted to cast a ballot for John Kasich, a Republican candidate in 2016.

Judge Carolyn McHugh wrote in the majority opinion that “electors, once appointed, are free to vote as they choose.”

“While the Constitution grants the states plenary power to appoint their electors, it does not provide the states the power to interfere once voting begins, to remove an elector, to direct the other electors to disregard the removed elector’s vote or to appoint a new elector to cast a replacement vote,” McHugh wrote.

However, Kagan rejected this reasoning, saying that because states appoint electors, they also may add requirements to their appointments.

“A state can require, for example, that an elector live in the state or qualify as a regular voter during the relevant time period,” Kagan wrote. She added that the state may insist that electors vote as pledged and “can demand that the elector actually live up to his pledge, on pain of penalty.”

She also noted that the vast majority of electors voted as they had pledged.

“The history going the opposite way is one of anomalies only,” she wrote. “And more than a third of the faithless votes come from 1872, when the Democratic Party’s nominee (Horace Greeley) died just after Election Day. Putting those aside, faithless votes represent just one-half of one percent of the total.”

She added that “nothing in this opinion should be taken to permit the states to bind electors to a deceased candidate.”

Conservative Justice Clarence Thomas, joined in part by Justice Neil Gorsuch, agreed with the majority’s decision, but said his reasoning fell under the principles of federalism — meaning that states share authority with the federal government.