United States Supreme Court Justice Anthony Kennedy, who has provided crucial swing votes in cases governing abortion rights and same-sex marriage, announced his retirement on Wednesday, CNN reported. His retirement is effective from July 31, according to a letter Kennedy sent to President Donald Trump.

Trump praised Kennedy for his years of service on the bench. “And I’m very honoured that he chose to do it during my term in office, because he felt confident in me to make the right choice and carry on his great legacy,” Trump said, adding that he hoped to nominate someone who would serve “40 or 45 years”.

Kennedy was nominated by President Ronald Reagan and sworn in in 1988. Although he was a Republican-appointed judge, he often was the “swing vote” between the four liberal justices and the four more conservative justices, including in the landmark ruling that recognised same-sex marriage in 2015.

The president’s first nominee to the court, conservative Justice Neil Gorsuch, has already had an enormous effect on US policy in narrowly decided rulings this week related to Trump’s ban on travel from certain countries, abortion and labor unions. The president said his next choice would come from a previously released list of 25 candidates, reported CNBC.

Indian-American judge Amul Thapar is among the shortlisted candidates, US media reports said. Thapar, who sits on the 6th US Circuit Court of Appeals, is a favorite of Senate majority leader Mitch McConnell, Courier Journal reported.

Senate Republicans will try to fill Kennedy’s seat before November. “We will vote to confirm Justice Kennedy’s successor this fall,” said McConnell. The Republican leader had blocked former President Barack Obama’s nominee – Judge Merrick Garland – to fill conservative judge Antonin Scalia’s seat, clearing the way for Trump to nominate Gorsuch.