Justice Anthony Kennedy announced Wednesday that he is retiring from the Supreme Court, a move that will give President Donald 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.

"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 to by conservatives who long for a more reliable vote to leave now, while his party controls the White House and the Senate.

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 honor 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.

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 anti-abortion 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.