It was not long after Anthony Kennedy announced his retirement as a Supreme Court judge that Washington tongues started to wag, with many insiders claiming Justice Kennedy's decision was made at the quiet behest of the Trump White House.

Justice Kennedy visited the White House on Wednesday to tell Mr Trump of his retirement. He also delivered a letter to the president. Its warm opening words - “My dear Mr President” - acknowledged the cordial relationship between the two men,

In many ways, Justice Kennedy's announcement vindicates the White House’s strategic flattery of the 81-year-old Californian.

In April 2017, Mr Trump first praised Justice Kennedy as “a great man of outstanding accomplishment".

“Throughout his nearly 30 years on the Supreme Court,” Mr Trump added, “Justice Kennedy has been praised by all for his dedicated and dignified service.”

The irony is that Justice Kennedy is reviled by many of Mr Trump’s supporters for voting to uphold access to abortion, limit the death penalty and expand gay rights. Conservatives have called for his impeachment. James Dobson, the founder of Focus on the Family, once called Mr Kennedy “the most dangerous man in America".

Mr Trump himself said he wanted to appoint justices who would overrule Roe v Wade, the 1973 decision establishing a constitutional right to abortion. Mr Kennedy has voted to reaffirm Roe. Moreover, Mr Trump has not held back from criticising far more conservative members of the Supreme Court, notably Chief Justice John Roberts Jr.

One person who knows both men says there is an affinity between Mr Trump and Mr Kennedy. This is not obvious at first glance. Mr Kennedy is bookish and abstract, whereas Mr Trump is abrasively direct.

But they had a connection - one Mr Trump was quick to note in the moments after his first address to Congress in February 2017. As he made his way out of the chamber, Mr Trump paused to chat with the justice.

“Say hello to your boy,” Mr Trump said. “Special guy.”

Mr Trump was apparently referring to Mr Kennedy’s son, Justin. The younger Mr Kennedy spent more than a decade at Deutsche Bank, eventually rising to become the bank’s global head of real estate capital markets.

Supreme Court pick Neil Gorsuch says 'no man is above the law' in questioning over President Trump

During Mr Kennedy’s tenure, Deutsche Bank became Mr Trump’s most important lender, dispensing well over $1bn (£761m) in loans to him for the renovation and construction of skyscrapers in New York and Chicago at a time when other mainstream banks were wary of doing business with him because of his troubled business history.

About a week before the presidential address, Ivanka Trump had paid a visit to the Supreme Court as a guest of the elder Mr Kennedy. The two had met at a lunch after the inauguration, and Ms Trump brought along her daughter, Arabella Kushner.

Ms Trump tweeted about the visit and posted a photo. “Arabella & me at the Supreme Court today,” she wrote. “I’m grateful for the opportunity to teach her about the judicial system in our country firsthand.”

The subtle overtures of the Trump White House were in stark contrast to the blunt rhetoric of its allies. Last month, Senator Charles Grassley of Iowa, the Republican chairman of the Senate Judiciary Committee, went on the radio to issue an urgent plea.

“My message to any one of the nine Supreme Court justices: if you’re thinking about quitting this year, do it yesterday,” he said

Mr Grassley added speed was of the essence in light of the midterm elections in November. “If we have a Democrat Senate,” he said, “you’re never going to get the kind of people that are strict constructionists.”

In pictures: President Donald Trump on tour Show all 39 1 /39 In pictures: President Donald Trump on tour In pictures: President Donald Trump on tour 20 May 2017 US President Donald Trump and Saudi Arabia's King Salman bin Abdulaziz al-Saud arriving for a reception ahead of a banquet at Murabba Palace in Riyadh Getty Images In pictures: President Donald Trump on tour 20 May 2017 US President Donald Trump, accompanied by First Lady Melania Trump, and Saudi Arabia's King Salman bin Abdulaziz al-Saud being welcomed at Murabba Palace in Riyadh Getty Images In pictures: President Donald Trump on tour 20 May 2017 US President Donald J. Trump with King of Saudi Arabia Salman bin Abdulaziz Al Saud during a welcome ceremony with traditional sword dancers at Murabba Palace, in Riyadh, Saudi Arabia EPA In pictures: President Donald Trump on tour 20 May 2017 King of Saudi Arabia Salman bin Abdulaziz Al Saud with US President Donald J. Trump and wife Melania during a welcome ceremony at Murabba Palace, in Riyadh, Saudi Arabia EPA In pictures: President Donald Trump on tour 20 May 2017 US President Donald Trump adjusts the Collar of Abdulaziz Al Saud Medal, after it was bestowed upon him by Saudi Arabia's King Salman bin Abdulaziz Al Saud at the Royal Court in Riyadh, Saudi Arabia Reuters In pictures: President Donald Trump on tour 20 May 2017 Saudi Arabia's King Salman bin Abdulaziz Al Saud presents U.S. President Donald Trump with the Collar of Abdulaziz Al Saud Medal at the Royal Court in Riyadh, Saudi Arabia Reuters In pictures: President Donald Trump on tour 21 May 2017 Palestinians print posters depicting US President Donald Trump in preparations for his planned visit, in the West Bank town of Bethlehem Reuters In pictures: President Donald Trump on tour 21 May 2017 US President Donald Trump accompanied by first lady Melania Trump, his daughter Ivanka Trump and her husband White House senior advisor Jared Kushner, before delivering his remarks to the Arab Islamic American Summit in Riyadh, Saudi Arabia Reuters In pictures: President Donald Trump on tour 21 May 2017 US President Donald Trump looks on as U.S. Secretary of State Rex Tillerson and Saudi Arabia's Crown Prince Muhammad bin Nayef exchange a memorandum of understanding Reuters In pictures: President Donald Trump on tour 21 May 2017 First Lady Melania Trump shares a laugh with a child during a visit to the American International School in the Saudi capital Riyadh Getty Images In pictures: President Donald Trump on tour 21 May 2017 US President Donald Trump holds a bilateral meeting with Bahrain's King Hamad bin Isa Al Khalifa AP In pictures: President Donald Trump on tour 22 May 2017 Israeli soldiers rest during preparations ahead of President Trump's landing in Tel Aviv, Israel Getty Images In pictures: President Donald Trump on tour 22 May 2017 First Lady Melania Trump makes her way to board Air Force One in Riyadh as she heads with her husband the US President to Israel Getty Images In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump and first lady Melania Trump board Air Force One for Israel, the next stop in Trump's international tour, at King Khalid International Airport AP In pictures: President Donald Trump on tour 22 May 2017 Israeli soldiers wait for the arrival ceremony of US President Donald Trump at Ben Gurion airport near Tel Aviv, Israel AP In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump and first lady Melania Trump arrive aboard Air Force One at Ben Gurion International Airport in Lod near Tel Aviv, Israel Reuters In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump and first lady Melania Trump disembark Air Force One on arrival at Ben Gurion International Airport AP In pictures: President Donald Trump on tour 22 May 2017 US President Donald J. Trump and his wife, US First Lady Melania Trump are welcomed by Israeli Prime Minister Benjamin Netanyahu upon arrival at Ben Gurion Airport, in Lod outside Tel Aviv, Israel EPA In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump and Israeli Prime Minister Benjamin Netanyahu sit during welcome ceremony in Tel Aviv AP In pictures: President Donald Trump on tour 22 May 2017 US First Lady Melania Trump chats wife Sara Netanyahu as US President Donald Trump chats to Israel's Prime Minister Benjamin Netanyahu during a welcoming ceremony to welcome Trump at Ben Gurion International Airport Reuters In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump delivers a speech upon his arrival at Ben Gurion International Airport in Tel Aviv Getty Images In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump gestures during a press conference with Israel's President at the President's Residence in Jerusalem Getty Images In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump watches as First Lady Melania Trump signs the guest book at the President's Residence in Jerusalem Getty Images In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump walks with first lady Melania Trump in Jerusalem's Old City Reuters In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump visits the Western Wall, the holiest site where Jews can pray, in Jerusalems Old City Getty Images In pictures: President Donald Trump on tour 22 May 2017 US President Donald Trump stands next to Rabbi Shmuel Rabinowitz at the plaza in front of the Western Wall, Judaism's holiest prayer site, in Jerusalem's Old City Reuters In pictures: President Donald Trump on tour 22 May 2017 US Secretary of State Rex Tillerson and White House senior advisor Jared Kushner leave notes at the Western Wall in Jerusalem Reuters In pictures: President Donald Trump on tour 22 May 2017 US First Lady Melania Trump touches the Western Wall, Judaism's holiest prayer site, in Jerusalem's Old City EPA In pictures: President Donald Trump on tour 22 May 2017 Ivanka Trump, assistant and daughter of US President Donald J. Trump, touches the Western Wall, Judaism's holiest prayer site, in Jerusalem's Old City EPA In pictures: President Donald Trump on tour 22 May 2017 President Donald Trump visits the Western Wall AP In pictures: President Donald Trump on tour 24 May 2017 US President Donald J. Trump arrives in a vehicle to Saint Damaso's Court for a private audience with Pope Francis in Vatican City EPA In pictures: President Donald Trump on tour 24 May 2017 Pope Francis walks past Ivanka Trump and First Lady Melania Trump on the occasion of the private audience with President Donald Trump, at the Vatican AP In pictures: President Donald Trump on tour 24 May 2017 Pope Francis exchanges gifts with US President Donald Trump during a private audience at the Vatican Getty Images In pictures: President Donald Trump on tour 24 May 2017 Pope Francis meets US President Donald Trump and his wife Melania during a private audience at the Vatican Reuters In pictures: President Donald Trump on tour 24 May 2017 Pope Francis with US President Donald J. Trump EPA In pictures: President Donald Trump on tour 24 May 2017 Pope Francis gets into is car after meeting with US President Donald Trump AP In pictures: President Donald Trump on tour 24 May 2017 President Donald Trump and his wife Melania look at the frescoed ceilings during their visit to the Sistine Chapel at the Vatican L'Osservatore Romano/Pool Photo via AP In pictures: President Donald Trump on tour 24 May 2017 US President Donald Trump security vehicles are seen in front of Air Force One before take off from Leonardo da Vinci-Fiumicino Airport in Rome, Italy Reuters In pictures: President Donald Trump on tour 24 May 2017 US President Donald Trump and First Lady Melania Trump wave to reporters before boarding the Air Force One to Brussels, at the end of a 2-day visit to Italy including a meeting with Pope Francis at the Vatican, at Rome's Fiumicino international airport AP

Intermediaries pressed the point with Mr Kennedy privately, telling him that Donald McGahn II, Mr Trump’s White House counsel, would in all probability leave after the midterms. Mr McGahn has been a key architect of Mr Trump’s successful efforts to appoint conservative judges, they said, and his absence would complicate a Supreme Court confirmation.

There is nothing particularly unusual in urging older justices to retire for partisan reasons. During the Obama administration, prominent liberals called for Justice Ruth Bader Ginsburg to retire so that Mr Obama could name her successor.

Mr Kennedy waited until the last day of the term to announce his retirement. The move disappointed liberals who had hoped that he would not want Mr Trump to name his successor. But the justice, saying he wanted to spend more time with his family, betrayed no hesitation.

His departure is a triumph for Mr Trump, who has taken particular satisfaction in his judicial appointments. Naming justices and judges is easier than forging legislative compromises. Mr Trump understands that his judicial appointments represent a legacy that will long outlast his presidency.

Replacing Mr Kennedy, who for decades held the decisive vote in many of the court’s closely divided cases, would give Mr Trump the opportunity to move the court sharply to the right.