It's a long article, but it's worth a read.
"December 8 is known as the “safe harbor” deadline for appointing the 538 men and women who make up the Electoral College. The electors do not meet until six days later, December 14, but each state must appoint them by the safe-harbor date to guarantee that Congress will accept their credentials. The controlling statute says that if “any controversy or contest” remains after that, then Congress will decide which electors, if any, may cast the state’s ballots for president.
We are accustomed to choosing electors by popular vote, but nothing in the Constitution says it has to be that way. Article II provides that each state shall appoint electors “in such Manner as the Legislature thereof may direct.” Since the late 19th century, every state has ceded the decision to its voters. Even so, the Supreme Court affirmed in Bush v. Gore that a state “can take back the power to appoint electors.” How and when a state might do so has not been tested for well over a century.
Trump may test this. According to sources in the Republican Party at the state and national levels, the Trump campaign is discussing contingency plans to bypass election results and appoint loyal electors in battleground states where Republicans hold the legislative majority. With a justification based on claims of rampant fraud, Trump would ask state legislators to set aside the popular vote and exercise their power to choose a slate of electors directly. The longer Trump succeeds in keeping the vote count in doubt, the more pressure legislators will feel to act before the safe-harbor deadline expires."
deleted by creator
Maybe https://en.wikipedia.org/wiki/Compromise_of_1877