The last time all this happened what did they do? Strike a deal

It was America's most hotly contested presidential election. The Democratic candidate was ahead in the popular vote. His Republican rival was heading for victory in the electoral college. Florida held the key, with both parties engaged in a ruthless battle to claim the state. The outcome in Oregon, as well as Florida, remained up for grabs.

The year was 1876.

If this month's presidential election in the US seems to set new standards for a close-fought contest that is bound to leave a big legacy of bitterness, consider the White House race 124 years ago between the Republican governor of Ohio, Rutherford Hayes, and the Democratic governor of New York, Samuel Tilden.

Early returns in the 1876 election suggested a comfortable victory for Tilden, seeking to recapture the presidency for the Democrats for the first time since the Civil War. When the votes were tallied, Tilden had 51% of the popular vote, against 48% for Hayes, a lead of more than 250,000 votes among the 8m cast.

Tilden had won the swing states of New York, Indiana and New Jersey. Assuming that he would win the southern states - which could be relied on to vote for the Democratic party in those days - Tilden went to bed thinking that he was one vote short of the 185 electoral college votes then needed for a majority.

But Tilden reckoned without Florida, whose four electoral college votes were among the southern total that both candidates were counting on to win.

The balloting and its aftermath in Florida, Louisiana and South Carolina were the focus of ferocious argument and manipulation.

Fraud raged on both sides. Boxes of votes were discovered hidden under water. Black voters were pivotal, with Republicans - the party of Lincoln - aggressively persuading blacks to vote while the Democrats, as the traditional party of the southern whites, struggled to stop them.

Physical intimidation and legal challenges abounded, and so did bribery. The results in Florida ended with both sides claiming victory. The Republicans said Hayes had it by 922 votes. Democrats said Tilden won by 94 votes. The US justice department sent detectives to Florida to investigate.

The election ended with all three southern states claimed by both sides and Oregon's votes also in dispute. To try to resolve the disputes, the US Congress was compelled to set up a 15-member bipartisan commission that included supreme court judges, senators and members of the House of Representatives.

By eight Republican votes to seven Democratic votes, the commission voted to accept the Republican claim in each of the cases, starting with Florida. Hayes was declared the winner by 185 electoral votes to 184 for Tilden,

Democrats threatened a filibuster as tensions rose again. Then, at the eleventh hour, the two parties struck a deal: Hayes would get the White House, as the committee had voted, but there would be a price: federal troops would be removed from southern states.

In effect, the arrangement returned the South to white rule for nearly a century.

On March 2 1877, just two days before the expiry of President Ulysses Grant's term, the US Senate confirmed Rutherford Hayes as his successor. During his single term he was known as "Mr Fraudulency".