I know that these are stressful times, what with Trump trying to game the elections, so I am here to tell you that no matter what he tries, we will get through this. And it is not, by far, the first time that this has happened. We got through it before, and we will get through it again. So let me share a story with you. It’s the story of Tilden versus Hays, two candidates for president in 1876.  This is from The Miller Center, and this is the first part of it (with link to the full story at the end): 
“In the presidential election of 1876, Democrat Samuel Tilden ran against Republican Rutherford B. Hayes. At the end of election day, no clear winner emerged because the outcomes in South Carolina, Florida, and Louisiana were unclear. Both parties claimed victory in those states, but Republican-controlled “returning” boards would determine the official electoral votes.
Republicans and Democrats rushed to those three states to watch and try to influence the counting of the votes. The returning boards determined which votes to count and could throw out votes, if they deemed them fraudulent. The returning boards in all three states argued that fraud, intimidation, and violence in certain districts invalidated votes, and they threw out enough Democratic votes for Hayes to win. All three returning boards awarded their states’ electoral votes to Hayes.
Meanwhile in Oregon, a strange development added that state to the uncertain mix. Hayes won the state, but one of the Republican electors, John W. Watts, was also postmaster, and the US Constitution forbids federal officeholders from being electors. Watts planned to resign from his position in order to be a Republican elector, but the governor of Oregon who was a Democrat, disqualified Watts and instead certified a Tilden elector.
Electors cast their ballots in state capitals on December 6, 1876. Generally, the process went smoothly but in four capitals—Salem, Oregon; Columbia, South Carolina; Tallahassee, Florida; and New Orleans, Louisiana — two sets of conflicting electors met and voted so that the US Congress received two sets of conflicting electoral votes. At this point, Tilden had 184 electoral votes while Hayes had 165 with 20 votes still disputed.”
Keep reading: https://millercenter.org/the-presidency/educational-resources/disputed-election-1876
Source