(CNN) Andrew Johnson faced overwhelming opposition in the House and the Senate, and he stood in the way of a Reconstruction that would have done more to help former slaves.
But he was still able, just barely, to survive a Senate impeachment trial.
Johnson was a Southerner and a Democrat, but he stayed on the Union side during the Civil War, and that helped him secure a place running alongside Republican President Abraham Lincoln in 1864, when Lincoln was reaching out to Democrats who had stayed loyal to the Union.
It also helped Johnson, who became President after Lincoln's assassination, stay in office when so-called "Radical Republicans" in the House impeached him for being too soft on the South -- because seven moderate Republicans in the Senate switched sides to save him.
Unlike President Donald Trump, who faces a hostile House but has a Senate majority on his side, Johnson was a Democrat running the country when most of the Democrats had been kicked out of Washington altogether. His party held a minority in both chambers of Congress, and the odds were stacked against him.
Yet seven senators abandoned their party and voted for his narrow acquittal to let Johnson finish out his term. He was ultimately succeeded by Northern Gen. Ulysses S. Grant.
In 1864, Lincoln was all about healing. His second inaugural address ends with words meant to bind a splintered nation together:
"With malice toward none, with charity for all, with firmness in the right as God gives us to see the right, let us strive on to finish the work we are in, to bind up the nation's wounds, to care for him who shall have borne the battle and for his widow and his orphan, to do all which may achieve and cherish a just and lasting peace among ourselves and with all nations."
A month and a half later, Lincoln, the Republican, was dead at the hand of an assassin and Johnson, his Democratic vice president, was in charge.
At the time, nobody in Washington was living up to the unifying goal of Lincoln's speech.
Johnson took a softer view of Reconstruction than the holdovers from Lincoln's Cabinet he kept in the government. Southern states had not yet earned back their seats in Congress. And the so-called "Radical Republicans," who wanted Reconstruction to do more to help former slaves and to punish the South, wanted more from their President. So they clashed.
The partisan divide in Washington then was so epic that Johnson still has more veto overrides -- 15 -- than any other President, ever.
One of the laws for which his veto was overridden was the Tenure of Office Act, by which the Republican-controlled Congress put a new check on his power and made it impossible to fire a Cabinet official without their OK. Johnson ignored the law to fire Secretary of War Edwin Stanton, who was more in line with the punitive Radical Republicans.
But the tenure law was essentially an impeachment trap. After Johnson ignored the new check, the House impeached him and Johnson was headed toward a conviction in the Senate.
The odds in the Senate were stacked against Johnson.
He was a Democrat, remember. Back then, there were just 47 Democrats in the House, compared with 173 Republicans. Impeaching him on 11 articles was no problem, since impeachment requires just a simple majority in the House and the vote against him was along party lines.
In the Senate, the odds were even worse: There were 57 Republicans, compared with just nine Democrats.
The attorney general at the time, Henry Stanberry, quit his day job to represent the President full time -- something that Trump's attorney general has not signaled plans to do. Stanberry helped lead a defense that centered on raising questions about Johnson's intent in violating the Tenure of Office Act and whether the offenses were actually criminal. Both of those arguments feel incredibly pertinent today, as Republicans defend Trump's actions in very similar ways.
Johnson's Senate trial, which was a sensational and crowded affair, went on for months. Seven Republican senators split from the rest of their party and voted against removing Johnson from office. They became known as the "Recusant Republicans," and offset the "Radical Republicans," who most opposed Johnson and were pushing a stricter Reconstruction.
Sen. Edmund Ross of Kansas is generally considered to have cast the deciding vote to acquit Johnson.
There are some allegations that Ross may have essentially been bribed or he didn't want to elevate Benjamin Wade, the ranking senator at the time, to the Presidency. Johnson, who as vice president succeeded to the White House after Lincoln's death, had no vice president of his own.
Ross got the hero treatment from John F. Kennedy in his book "Profiles in Courage." His vote helped preserve the modern, powerful presidency. The Supreme Court said in 1926 that the Tenure of Office Act was unconstitutional. But Johnson's Presidential career was over after he was impeached, because he lost the Democratic Party's nomination for the 1868 election, and Democrats lost the White House to Grant.
The Union survived both Civil War and Johnson's impeachment and emerged with a strong executive. Johnson ultimately won back his old Senate seat from Tennessee, and a place in the history books.
While Kennedy called the decision to vote to acquit Johnson a "profile in courage," the larger narrative of Johnson's presidency is not a good one. He made it easier for Southern states to reenter the Union and pardoned the Vice President of the Confederacy, perhaps helping to sew the nation back together but doing little to address the plight of African Americans in the South. He was a racist who opposed the Emancipation Proclamation and blocked efforts to help Southern blacks find their footing post-slavery.
"He utterly failed to make a satisfying and just peace because of his racist views, his gross incompetence in federal office, and his incredible miscalculation of public support for his policies," wrote Elizabeth Varon, a history professor at the University of Virginia. He "tried to preempt and then undermine Congressional Reconstruction by deeming the Republican experiment in black citizenship a failure, and by portraying former Confederates as victims of Republican misrule."
It was also an unhappy decision for the seven Republicans who voted to acquit him. They might have saved the powerful executive system, but they lost their jobs. None were reelected to the Senate and they faced personal repercussions as well. According to a Senate history, Ross was ostracized and his family fell into poverty when they returned to Kansas.
CORRECTION: This story has been updated to reflect that Civil War was not yet over when Lincoln was re-elected.