Wednesday, after a half-century of struggle, conservatives took back the Supreme Court. Justice Anthony M. Kennedy, a moderate-conservative, announced his retirement, offering President Trump the opportunity to lock in a right-wing majority on the court for years to come.

Unless Trump fumbles the opportunity — not impossible, given the general incompetence of his administration — the completion of a half-century-long political quest will make for the most conservative court since the 1930s. That revolution threatens to undo a host of liberal rulings, as well as the ability of future liberal governments to enact their agendas.

The conservative war to reclaim control of the courts began in the 1950s and 1960s. Conservatives loathed the decisions of the liberal Warren Court (named for Chief Justice Earl Warren) on issues including desegregation, school prayer and criminal procedure. The court also paved the way for liberal legislation such as the Civil Rights Act, with its broad interpretation of the federal government’s power.

Their counterrevolution won its first victory in 1968 when a coalition of conservative Southern Democrats and Republicans blocked President Lyndon B. Johnson from replacing Warren. Johnson was not blameless — by nominating his close friend Justice Abe Fortas to replace Warren, and another friend, Judge Homer Thornberry, to replace Fortas, he exposed himself to charges of cronyism — but the filibuster that killed the Fortas nomination was unprecedented and handed the power to replace Warren to Johnson’s successor, President Richard M. Nixon.

In many ways, it marked the beginning of the modern judicial wars.

From there, the counterrevolution slowly moved forward. Nixon, his Justice Department and conservative congressional allies hounded Fortas from the court in 1969 amid ethical allegations, eager to create another vacancy and change the court’s ideological balance.

But Nixon and his successor, Gerald Ford, failed in this regard. Of their five appointments, four ended up presiding as moderate to liberal justices. That happened for a few reasons: Ford focused on competence instead of ideology, and the Senate rejected two of Nixon’s most conservative nominees, Clement Haynsworth over ethical issues and civil rights, and G. Harrold Carswell, thanks to his gross incompetence and manifest bigotry.

Nixon’s most conservative appointment — highly conservative in the context of the times — was William Rehnquist. But even Rehnquist, who would later become chief justice, had a pragmatic streak that future conservative justices such as Antonin Scalia lacked.

Left to these presidents, the counterrevolution would have fizzled out. But the conservative movement stepped in to help. The Federalist Society, a conservative legal organization founded in 1982, played a seminal role in transforming the court. It created a network of conservative lawyers and law students who ensured ideology would play a major role in who received clerkships for conservative jurists, as well as administrative posts in Republican administrations.

Beefed-up résumés and a conservative ideological stamp of approval helped these lawyers qualify for judgeships at a young age. Once on the bench, they compiled a track record that made it easier for Republican presidents to avoid being unpleasantly surprised by the judicial philosophies of their court appointments, as Dwight Eisenhower had been by Warren and William Brennan, and Nixon was by Harry Blackmun.

The Federalist Society also helped promote a conservative jurisprudence, advancing ideas such as originalism, the notion that judges should be focused on ferreting out what the text of statutes and the Constitution meant at the time they were enacted. This contrasted with the Warren Court, which focused on interpreting a “living” Constitution in light of modern circumstances.

In 1986, President Ronald Reagan appointed Scalia — a hero and adviser to many of the young conservatives who launched the Federalist Society. Scalia blazed a path for originalism and created a model for what Republican presidents wanted from Supreme Court appointees: justices who would focus on the meaning of statutory and constitutional text, not broader societal factors or legislative history. This approach left little room for identifying new rights or extending protections to new populations while also safeguarding traditional cultural norms and giving advantages to states and corporations at the expense of the federal government.

Perhaps the two most important appointments came in 1991 and 2006. In 1991, a Democratic-controlled Senate confirmed the highly conservative Clarence Thomas to succeed ultraliberal Thurgood Marshall. Such a move would be unimaginable in today’s polarized climate. Eleven Democrats, many of them Southerners with large African American bases, supported Thomas’s nomination, prioritizing politics over concerns about Thomas’s judicial philosophy. In 2006, Samuel A. Alito Jr. (so conservative he was nicknamed Scalito) succeeded the moderately conservative Sandra Day O’Connor, again shifting the balance of the court right.

Although it looked as though Scalia’s death during Barack Obama’s presidency might give Democrats an opening to tip the balance of the court back toward the left — and significantly so, following the confirmations of Elena Kagan and Sonia Sotomayor — the unprecedented obstructionist tactics of Senate Majority Leader Mitch McConnell (R-Ky.) prevented it.

Last year’s appointment of Neil M. Gorsuch thus left the court divided. There were four liberal Democratic appointees, three far-right conservatives, the conservative Chief Justice John G. Roberts Jr. and Kennedy, the swing vote who has shaped the court profoundly in the 12 years since O’Connor retired.

With Kennedy’s retirement, a Republican president and a Republican Senate, as well as the neutering of the Senate filibuster with regard to judicial nominees, it seems as though the way is clear to finally have a staunchly conservative five-justice majority on the court. And given that Thomas, at 70, is the oldest of the bloc, and that Republicans have shown a willingness to block nominations until a Republican is president, that majority is likely to remain in place for years.

The rise of the Federalist Society, which consulted with Trump on his list of potential Supreme Court appointments, has made it easier for Republican presidents to identify committed conservatives who won’t migrate to the left over time. It’s no coincidence that Republican presidents’ past four court appointments have been staunch conservatives. They’ve cracked the code and discovered how to deliver what their base demands — judges chosen first and foremost for their fealty to conservative legal principles.

This means that Kennedy’s retirement puts abortion rights, gay rights, voting rights and many other liberal precedents squarely on the chopping block. The decision legalizing same-sex marriage, to name but one, was determined by a 5-to-4 vote, with Kennedy in the majority.

More broadly, the newly conservative court probably will take a far narrower view of the federal government’s power. This has the potential to hamstring future liberal governments, just as many Supreme Court rulings in the 1930s frustrated President Franklin D. Roosevelt, prompting him to unsuccessfully attempt to pack the court.

Kennedy’s retirement is, thus, a dark day for American liberals and a gleeful one for conservatives. It promises to be highly momentous, and it represents the completion of a counterrevolution that could have a lasting impact on millions of Americans for generations.