WASHINGTON—The Supreme Court on Friday agreed to take a rare look at rules for electing U.S. presidents, saying it will decide whether a state’s appointed presidential electors can vote in the Electoral College for a candidate who didn’t win the state’s popular vote.

The court’s eventual decision could have ramifications for razor-thin presidential elections if enough members of the Electoral College seek to break rank and cast ballots that depart from the will of the voters.

The high court said it would hear a pair of cases from Colorado and Washington where state law requires presidential electors to vote for the presidential candidate that won the statewide vote.

In the 2016 election, one Colorado elector was replaced when he cast a vote for Ohio Republican John Kasich instead of Hillary Clinton, the Democratic presidential nominee who carried the state.

A divided federal appeals court sided with the faithless elector last year, ruling Colorado violated the Constitution by nullifying his vote. That court said that while a state has the power to pick its electors, those electors have the discretion to vote for whom they wish.