The Supreme Court’s health-care ruling is welcome because it is a compromise. The justices overcame their differences, defusing political conflict and channeling it into the election where it belongs.

But the ruling is historic because it is a Compromise — a crisis-averting pact across lines of ideology, party and region, the likes of which we have not seen since pre-Civil War days.

Four of the court’s five Republican-appointed conservatives wanted to strike down the Democratic Party’s most cherished legislative achievement since the Great Society, dealing an election-year political blow to President Obama.

Their legal arguments were hardly specious, but they were novel enough to be plausibly branded partisan and opportunistic — possibly in a dissenting opinion by four liberal Democratic appointees on the court that would have become a de facto Obama campaign manifesto.

For Chief Justice John Roberts, the temptation to join the other four GOP appointees, consequences be damned, must have been strong. Surely this lifelong conservative has little use for “Obamacare.”

Yet he is also a student of history, especially pre-Civil War America; his intellectual biography of Daniel Webster won Harvard’s undergraduate writing prize in 1976. If anyone sees a parallel between today’s polarized politics and those of Webster’s time, it would be Roberts. No one understands the United States’ constitutional strengths, and vulnerabilities, better than he.

Roberts grasped two realities. First: In a great national debate, no side has a monopoly on wisdom. Second: Conservatism has no future if the country slides into division and dysfunction.

And so, instead of standing on the legal principles articulated by his conservative brethren, Roberts sacrificed some of those precepts and persuaded some court liberals to reciprocate.

This was no capitulation. Roberts dealt from strength, holding four aces named Anthony Kennedy, Antonin Scalia, Clarence Thomas and Samuel Alito.

What emerged was less a legal opinion than a plan for national cohesion, on terms remarkably favorable to conservatives.

First, Medicaid. Some 26 mostly red states sued to block the Affordable Care Act’s expansion of Medicaid, arguing that it unconstitutionally coerced them to participate. The court upheld this claim in a 7 to 2 ruling. Liberals Stephen Breyer (a former aide to health-care hero Ted Kennedy) and Elena Kagan (Obama’s own appointee) joined the decision, in return for Roberts’s agreement not to strike the provision entirely but to remedy the constitutional violation by letting states opt out of the expansion without penalty.

In short, the liberals saved the plan for the blue states by letting the red ones go.

The Compromise of 1850 reaffirmed the north-south line between slave states and free states. The Roberts court penciled a red-blue line on Medicaid.

To be sure, Roberts had to stomach the individual mandate, just as Webster in 1850 accepted the morally incomparable but also unpopular mandate known as the Fugitive Slave Law, which required individuals to aid slave catchers.

Webster’s anti-slavery friends ostracized him, just as some conservatives bash Roberts. But, like Webster, who could point to the admission of a free California and the abolition of the slave trade in Washington, D.C., Roberts has won long-term gains for his side. The Medicaid precedent sets up conservative challenges to federal spending; the five-justice vote for a restrictive reading of the Constitution’s commerce clause caps that font of federal power.

Finally, Roberts’s nonpartisan performance has earned respect and political capital that may help him achieve key conservative goals on voting rights and affirmative action in cases next term.

Conservatives reproach Roberts for activism, saying he “rewrote” Obamacare. He sure did. Formerly, it embodied progressive hopes for a more active federal government and a Democratic political majority. Now, it’s truncated and facing a political battle royale in November with a big “tax” sign around its neck.

How the Compromise of 2012 plays out is, of course, beyond Roberts’s control, just as Webster could not foresee the divisive 1854 Kansas-Nebraska Act or the Dred Scott case. May today’s politicians make better use of the time the court has just bought.

“A deep respect for courageous intentions and righteous politics courses through Roberts’s college papers” about Webster and others, conservative journalist Matthew Continetti wrote in 2005. As Continetti noted, Roberts was “most eloquent” in describing the “Websterian leader” as “a man of character, a disinterested, self-sacrificing man of wisdom who continually worked with others of his sort to resolve any controversy which threatened national harmony. The man of character did not fight in the thick of political battles, but rather raised himself above the conflict and stilled it through dispassionate compromise.”

That is the kind of leadership John Roberts has just provided his country, his court and, indeed, conservatism.