Supreme Court Justice Anthony Kennedy announced Wednesday that he will retire on July 31 — giving President Trump an opportunity to cement conservative control of the court.

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

Trump lavished praise on Kennedy — the longest-sitting justice on the current court — during a White House meeting with Portugal’s president, ­Rebelo de Sousa.

“He’s been a great justice of the Supreme Court. He is a man who has displayed tremendous vision and tremendous heart, and he will be missed,” Trump said.

“I just want to thank Justice Kennedy for the years of tremendous service. He is a very spectacular man, really is a spectacular man.”

The president said he would select a nominee from the same list of roughly 25 potential candidates — all solid conservatives — that he released during his campaign for president.

“We have a very excellent list of great talented, highly educated, highly intelligent, hopefully tremendous people. I think the list is very outstanding,” Trump said.

Democrats and abortion-rights advocates said they feared that without Kennedy’s swing vote in favor of upholding Roe v. Wade, the court would likely overturn the landmark 1973 decision legalizing abortion.

Sonia Ossorio, president of the New York City branch of the National Organization for Women, called news of Kennedy’s retirement “devastating” and predicted it would be the death knell for Roe.

“There’s no doubt that the president is going to appoint a conservative, making it virtually certain there will finally be enough votes to overturn Roe v. Wade,” she told The Post.

Democratic New York Sen. Kirsten Gillibrand wrote on Twitter: “The president just said the next Supreme Court nominee WILL come from his list of 25 judges that passed his overturning Roe v. Wade litmus test. We need to say NO hearings before the election and work our hearts out and take back the Senate.”

Trump, asked if would consider waiting until after the November elections before announcing a nomination, replied: “I think you want to go as quickly as possible.”

And Senate Majority Leader Mitch McConnell echoed that sentiment.

“We will vote to confirm Justice Kennedy’s successor this fall,” he declared on the Senate floor.

But Senate Democratic leader Chuck Schumer, citing McConnell’s maneuvering in 2016, called on him to delay a vote until after the midterms.

In February of that year, the death of Justice Antonin Scalia created a vacancy on the high court and then-President Barack Obama nominated Merrick Garland the following month.

But McConnell used his power to delay a vote until after the presidential election, and when Trump won, Garland was cast aside and conservative Neil Gorsuch was nominated and got the seat.

Confirming Kennedy’s replacement would require a simple majority in the 100-seat Senate, where Republicans currently hold 51 seats.

Legal experts said a Trump nomination could make abortion an issue in the midterms.

“The Kennedy vacancy brings abortion rights to the fore … because women can no longer take Roe v. Wade and judicial protection of reproductive rights for granted,” tweeted Harvard University law professor Lawrence Tribe.

An appointee of President Reagan, Kennedy has been on the high court since 1988.

He was famed for frequently being a swing vote in 5-4 decisions.

Kennedy has cast the key vote on such high-profile issues as abortion, affirmative action, gay rights, guns, campaign finance and voting rights.

The president’s evangelical base has long held out hope that Trump would be in a position to appoint another staunch conservative.

Kennedy’s decision to step down came after the court voted 5-4 in two landmark cases this week — a ruling that Trump’s immigration ban targeting mostly Muslim-majority countries was legal, and that workers could not be forced to pay public-employee union fees if they didn’t join.

Additional reporting by Mark Moore with Wires