In the 2014 midterm elections Republicans took control of the Senate and won more House seats than at any point in almost 70 years. “Obviously,” said President Obama the morning after, “Republicans had a good night.” Senator Joe Manchin III (D-W.Va.) was more blunt: “This is a real ass-whuppin’.”

The party of a president who is serving a second term often suffers from the electorate’s six-year itch. Once fresh faces have become all too familiar. So have the majority party’s policies. In 2006 Democrats capitalized on George W. Bush’s Iraq War gone wrong; in 1938 Republicans undercut FDR’s overambitious plan to pack the Supreme Court. But even Election Day losers can still make bold, or desperate, efforts to secure their legacy.

Beginning in 1868 the Republican Party dominated national politics. Civil War hero Ulysses Grant won the presidency twice, and Republicans controlled both houses of Congress. In 1874, midway through Grant’s second term, that changed. The GOP lost only one seat in the Senate, retaining a solid edge. But the Republican House delegation was cut almost in half, from 203 representatives to 110—still the largest loss of House seats in GOP history. Victorious Democrats saw their ranks swell from 89 to 179. (There were also a few Independents.)

Voters punished Republicans for greed, corruption and hard times. In 1873 Congress had given itself a pay raise, retroactive for two years—a move dubbed the Salary Grab. In 1874 Grant’s treasury secretary resigned because of irregularities in pursuing tax delinquents. A bank panic settled into a long, grinding depression.

But the Republican Party’s fortunes were inextricably tied to its most important post–Civil War policy: the Reconstruction of the defeated South. Having won the war Republicans had to win the peace, but Reconstruction got off to an unsteady start. In the last days of his life, Abraham Lincoln suggested that Rebel states be reintegrated into the Union as soon as possible and that at least some black men get the vote. His successor, Andrew Johnson—no Republican, but a pro-war Democrat who had been put on the 1864 ticket to balance it—pursued Lincoln’s first goal but not his second: State governments were reestablished throughout the South, but they imposed stringent codes regulating the labor of blacks and denying them a political voice.

In 1867 Republicans in Congress, led by pro–black rights Radicals like Charles Sumner and Thaddeus Stevens, took Reconstruction into their own hands, requiring Southern states to adopt constitutions that established black suffrage. As a last resort, the U.S. Army would enforce federal law. The Republicans impeached Johnson and came within an ace of removing him from office. Grant was elected in 1868 as the Radicals’ candidate.

Radical Reconstruction formally allowed black civic engagement for the first time in American history. Southern states elected one black governor, two U.S. senators, 14 congressmen and numerous holders of lesser offices. Reconstruction also empowered white Southerners who had opposed secession—upcountry small farmers who had been shut out of power by planters—and Northerners who came south to uplift blacks or, less creditably, themselves. Southern Democrats naturally resented their new masters, hating politically active blacks and branding their white allies scalawags (if they were natives) or carpetbaggers (if they were newcomers). As time went on, however, Reconstruction became increasingly unpopular with the Northern public.

One problem was corruption. Reconstructed state governments spent a lot of money on schools, railroads and other public works, and some of it ended up in the pockets of lawmakers, white and black. Corruption was endemic in American political life, from the Grant administration to Tammany Hall, but accounts of corruption in the Reconstructed South were tinged with racism. South Carolina, reported one Northern journalist, labored under “a mass of black barbarism.”

Reconstruction benefited the GOP, since Southern blacks voted Republican. But once Reconstruction was seen as a partisan policy—“a struggle,” as one observer disdainfully called it, “for the loaves and fishes”—it lost the support of liberal reformers eager to elevate the tone of politics. Republican liberals bolted the party and held their own political convention in Cincinnati in 1872, nominating veteran journalist Horace Greeley to oppose Grant. (Greeley also got the Democratic Party’s nod.) Greeley, who had a long record of supporting high-minded causes, ran on the noble-sounding platform of “local self-government,” which in the South would mean white rule. Grant thrashed him, but liberals remained disaffected.

What most undermined Reconstruction, however, was the difficulty of enforcing it. The Ku Klux Klan, originally a social club for ex-Confederate officers, became, in the words of historian Eric Foner, “a military force serving the interests of the Democratic Party,” intimidating and murdering blacks, scalawags and carpetbaggers. In 1871 Congress had passed the Ku Klux Klan Act and Grant’s attorney general, Amos Ackerman, indicted hundreds of Klansmen in the Carolinas and Mississippi. As a result the Klan temporarily collapsed and 1872 saw what historian James McPherson called “the fairest and most democratic presidential election in the South until 1968.” But violence resumed in Louisiana, culminating in a pitched battle in New Orleans in September 1874. Thirty-five hundred members of the Klan-like White League overpowered a force of police and militia commanded by Confederate turned Republican James Longstreet, and captured city hall and the state house. Grant sent 5,000 troops and three gunboats to restore order. Six weeks later Republicans were routed at the polls nationwide.

Representative James Garfield (R-Ohio) attributed Republican losses to “a general apathy among the people concerning…the negro.” The election results certainly emboldened Southern insurgents. In December 1874 Mississippi’s White League drove the black sheriff of Vicksburg out of town, and moved through the countryside murdering blacks. Louisiana politics still festered, and the balance of power in the state legislature hung on the results of a handful of disputed elections.

Grant held firm at first. In January 1875 he sent federal troops to Vicksburg to restore its sheriff, and dispatched his old cavalry commander Philip Sheridan to evaluate the situation in New Orleans. Sheridan threw out the Democratic claimants, called for martial law and compared the White Leagues to “banditti.” Grant defended Sheridan’s brusque behavior, but he would not declare martial law and accepted a congressional report that divided control of the Louisiana government between Republicans and Democrats. Grant too sensed that the North was no longer willing to fight Southern Democrats. “The whole public,” he wrote in September 1875, is “tired out with these annual autumnal outbreaks in the South.” More accurately, Grant and the public were tired of suppressing them.

The presidential election of 1876 produced a famous deadlock between Democrat Samuel Tilden and Republican Rutherford B. Hayes. Part of the deal by which Democrats accepted defeat was Hayes’ pledge to end Reconstruction in the South. But even a clear win by Hayes would have produced some such result: He had promised during his campaign to support “honest and capable local self-government” in the South—Horace Greeley’s old program rephrased. The Republicans abandoned an unpopular policy, politics moved on and blacks would legally be second-class citizens for 90 years.

Democrats in 2014 faced stubborn problems: a lingering war in Iraq, a new war in Syria and a still sluggish economy. President Obama’s personality had not changed, but opinions of it had: A demeanor that once seemed calm and cerebral had come to look aloof and arrogant. Congressional Democrats paid the price. Yet Obama is still president, and like Grant in early 1875, he is still capable of bold moves: In November he essentially granted amnesty from deportation to 5 million illegal immigrants by executive order. American politics accommodates both wave elections and rear-guard actions. By design the government has many moving parts, and they do not all move at the same time.