WASHINGTON — Justice Anthony Kennedy announced Wednesday that he is retiring from the Supreme Court, a move that will give President Trump a chance to replace the pivotal justice and solidify a more conservative majority on the court that plays a crucial role in American life.

Supreme Court Justice Anthony Kennedy is stepping down from the court at the age of 81. Bloomberg photo by T.J. Kirkpatrick

“It has been the greatest honor and privilege to serve our nation in the federal judiciary for 43 years, 30 of those years on the Supreme Court,” Kennedy, 81, said in a statement released in the afternoon of the last day of the term. He said his final day will be July 31.

Kennedy’s pivotal role at the center of a court equally balanced between more predictable conservatives and more consistent liberals made him the most essential member of the modern court.

His opinions often spoke of “dignity” and “liberty,” and his notions of how the Constitution provides for and protects them had an outsize effect on Americans.

Kennedy cast the deciding vote that found a constitutional right for same-sex couples to marry. He determined how far government may intrude on a woman’s right to an abortion; whether attempts to curtail the corrupting influence of campaign contributions violated free speech; and how and when it is appropriate for government to exercise affirmative action.

His decisions shielded juveniles and the intellectually disabled from the death penalty, although he refused to find capital punishment unconstitutional. He found that those seized in the fight against terrorism had rights in U.S. courts. And that is only a partial list of the issues on which he was key.

His retirement had been rumored. The lifelong Republican was openly encouraged by conservatives who long for a more reliable vote to leave now, while his party controls the White House and the Senate.

Justice Kennedy letter to President Trump

Democrats and liberals, who thought of him as the best they could hope for, begged him to stay.

There seems little doubt that his successor will be more aligned on the right.

“An already right-leaning Supreme Court is poised to become the most conservative institution in the entire history of America’s government,” said Thomas Goldstein, a Washington lawyer and founder of SCOTUSblog.com.

“Justice Kennedy was the last obstacle to reshaping our law on a host of hot-button issues.”

Kennedy informed Trump of his decision in a letter.

“My dear Mr. President,” he wrote. “For a member of the legal profession it is the highest of honors to serve on this court. Please permit me by this letter to express my profound gratitude for having had the privilege to seek in each case how best to know, interpret and defend the Constitution and the laws that must always conform to its mandates and promises.”

A Supreme Court news release from Kennedy said that his family was willing for him to continue to serve, but that he had “a deep desire to spend more time with them.”

Kennedy visited with the president in the White House on Wednesday, and they met for about half an hour, Trump said. The president said he asked whether Kennedy had any recommendations for his replacement, but did not say whether Kennedy answered.

“Hopefully,” Trump said, “we will pick someone who is just as outstanding.”

Kennedy’s colleagues also did not receive much warning of his announcement. There was no mention of it as the court delivered its final decisions of the term.

“His jurisprudence prominently features an abiding commitment to liberty and the personal dignity of every person,” Chief Justice John Roberts Jr. said in a statement. “Justice Kennedy taught collegiality and civil discourse by example.”

The Californian joined the court in 1988 as a compromise choice of President Ronald Reagan, and has been the deciding vote on so many issues that Erwin Chemerinsky, now dean at the University of California Berkeley School of Law, once joked that he “would put Justice Kennedy’s photo on the cover” of a brief if the court’s rules allowed it.

Although Kennedy held the deciding vote on many issues, abortion is likely to be the key focus in what is expected to be a bruising nomination battle for his successor.

President Trump and Justice Anthony Kennedy walk together after Justice Neil Gorsuch was administered the oath of office on April 10, 2017. Trump said he asked Kennedy for suggestions on his successor. Washington Post/Jabin Botsford

Trump promised during the campaign that he would try to overturn Roe v. Wade. “Well, if we put another two or perhaps three justices on, that’s really what’s going to be – that will happen,” Trump said during a debate.

Forces on both sides of the abortion fight made it clear that they are prepared for battle.

“The most important commitment that President Trump has made to the pro-life movement has been his promise to nominate only pro-life judges to the Supreme Court, a commitment he honored by swiftly nominating Judge Neil Gorsuch,” said Marjorie Dannenfelser, president of the Susan B. Anthony List, an antiabortion group.

She added: “We trust him to follow through on his promise.”

Abortion rights supporters were on high alert.

“That promise should set off alarm bells for anyone who cares about women – and the Constitution,” said Nancy Northup, president and chief executive of the Center for Reproductive Rights. She added: “The future of reproductive rights is on the line.”

Others said the stakes are bigger than that.

“This is a monumental moment for our country,” said Sherrilyn Ifill, president and director-counsel of the NAACP Legal Defense Fund. “The very integrity of our justice system and the rule of law will be affected by the confirmation of a new justice to the Supreme Court.”

Trump has publicized a list of 25 state and federal judges from which he has said he will choose. Among the names sure to get a close look, according to those involved in the process, are:

Brett Kavanaugh, a former Kennedy clerk who serves on the U.S. Court of Appeals for the District of Columbia Circuit and was added in November; Thomas Hardiman, a judge on the U.S. Court of Appeals for the 3rd Circuit; Amy Coney Barrett, a recent addition to the U.S. Court of Appeals for the 7th Circuit; Raymond Kethledge and Amul Thapar, both of the U.S. Court of Appeals for the 6th Circuit. Allison Eid, a judge on the U.S. Court of Appeals for the 10th Circuit, is also a Trump nominee.

All are more conservative than Kennedy, and any replacement will move the court to the right and place Roberts in the pivotal role on the nine-member court. Roberts, 63, also has shown himself to be well to the right of Kennedy.

Senate Majority Leader Mitch McConnell, R-Ky., changed the Senate rules during the battle over Trump’s first choice for the court, Neil Gorsuch, to require only a majority of senators for confirmation.

Senate Democrats lack the numbers to deny the seat to Trump’s pick on their own, but will increase the stakes of the choice.

Kennedy’s legacy on the court probably will be defined to a great extent by the decisions he wrote championing gay rights: striking down discrimination, restrictions on sodomy and the federal government’s position of not recognizing legal same-sex marriages.

The culmination was his opinion in Obergefell v. Hodges in 2015, in which the court’s four liberals joined him in finding that it violated the Constitution for states to offer marriage licenses only to heterosexual couples.

“The limitation of marriage to opposite-sex couples may long have seemed natural and just, but its inconsistency with the central meaning of the fundamental right to marry is now manifest,” he wrote. “With that knowledge must come the recognition that laws excluding same-sex couples from the marriage right impose stigma and injury of the kind prohibited by our basic charter.”

Many conservatives were outraged by the decision, saying Kennedy’s amorphous style of constitutional interpretation was simply a way to impose policy decisions he preferred, rather than those the Constitution delegates to voters or their elected representatives.

Justice Antonin Scalia, a fellow Reagan nominee, led the way in criticism, calling Kennedy’s lofty language “as pretentious as its content is egotistic.”

Kennedy also leaves a long list of clerks who now populate academia and the federal courts. When Gorsuch was confirmed, he became the first former clerk to sit on the Supreme Court with the justice for whom he worked.

Michael Dorf, a law professor and former clerk, remembered Kennedy in a blog post.

“Justice Kennedy leaves behind a legacy of libertarianism and constitutional patriotism,” Dorf wrote. “Even when I disagreed with Justice Kennedy (which was often) I admired his sincerity. He did not like to be called the ‘swing justice,’ because he saw himself as applying principles even-handedly rather than swinging one way or the other.”

At times, that meant big victories for the left.

Two terms ago, Kennedy voted with the court’s liberals to strike down a Texas law that the court said used protecting women as a pretext for making abortion unavailable, and the court continued a limited endorsement of affirmative action.

This term, he sided almost exclusively with fellow conservatives. Not once in a 5-to-4 decision did Kennedy join the liberals.

Among those liberals are Justices Ruth Bader Ginsburg, 85, and Stephen Breyer, who will turn 80 this summer.

Gorsuch’s appointment returned the court to the status quo that existed before Scalia died in 2016. But a court without Kennedy will be a different place.

Many, if not all, of Kennedy’s decisions will be at risk in a court with five consistent conservatives, the oldest being Justice Clarence Thomas, 70.