WASHINGTON — President Trump singled him out for praise even while attacking other members of the Supreme Court. The White House nominated people close to him to important judicial posts. And members of the Trump family forged personal connections.

Their goal was to assure Justice Anthony M. Kennedy that his judicial legacy would be in good hands should he step down at the end of the court’s term this week, as he was rumored to be considering. Allies of the White House were more blunt, warning the 81-year-old justice that time was of the essence. There was no telling, they said, what would happen if Democrats gained control of the Senate after the November elections and had the power to block the president’s choice as his successor.

There were no direct efforts to pressure or lobby Justice Kennedy to announce his resignation on Wednesday, and it was hardly the first time a president had done his best to create a court opening. “In the past half-century, presidents have repeatedly been dying to take advantage of timely vacancies,” said Laura Kalman, a historian at the University of California, Santa Barbara.

But in subtle and not so subtle ways, the White House waged a quiet campaign to ensure that Mr. Trump had a second opportunity in his administration’s first 18 months to fulfill one of his most important campaign promises to his conservative followers — that he would change the complexion and direction of the Supreme Court.