Supreme Court Justice Anthony Kennedy seemed to partly rebuke President Donald Trump in his concurring opinion in Tuesday's decision on Trump's travel ban.

While Kennedy upheld the travel ban, he warned that government officials are not "free to disregard the Constitution and the rights it proclaims and protects.”

Kennedy, 81, announced his retirement from the Court on Wednesday.

On the day before he announced his retirement, Supreme Court Justice Anthony Kennedy was in the majority opinion on one of his final rulings: upholding the Trump administration's travel ban.

But Kennedy didn't leave the bench without taking some shots at President Donald Trump's views on immigration.

The case, Trump v. Hawaii, revolved around the Trump administration's third attempt to enact restrictions on immigration from seven Muslim-majority nations. The court agreed with the the Trump administration's defense that the ban is justified by legitimate national security concerns, but the plaintiffs said it constituted religious discrimination.

In a 5-4 decision, the court ruled that such a ban fell well within the administration's jurisdiction and authority over national security and immigration policy, and was reasonably backed by national security concerns.

In his concurring opinion, Kennedy sent a not-so-subtle warning to Trump about how his words and policies could come into conflict with the fundamental principles of the Constitution.

"There are numerous instances in which the statements and actions of Government officials are not subject to judicial scrutiny or intervention," Kennedy wrote. "That does not mean those officials are free to disregard the Constitution and the rights it proclaims and protects."

"It is an urgent necessity that officials adhere to these constitutional guarantees and mandates in all their actions, even in the sphere of foreign affairs," he continued. "An anxious world must know that our Government remains committed always to the liberties the Constitution seeks to preserve and protect, so that freedom extends outward, and lasts."

Kennedy, who is 81 and was appointed to the court by President Ronald Reagan, announced his retirement in a statement on Wednesday. Throughout his career, he has been considered to be a "swing vote" on the court, often being the deciding vote on key cases.

Law professor Richard Hasen, writing in a Slate article published Tuesday, predicted that Kennedy's partial rebuke of Trump was a foreshadowing of his retirement. Hasen called it an expression of "depressing defeatism" regarding the court's ability to rein in elected officials whose actions contradict the spirit of the Constitution.

Trump nominated current Justice Neil Gorsuch to fill the seat vacated by the death of Antonin Scalia in January 2017. Kennedy's retirement means that Trump will be able to shift the balance of power on the court to make it even more conservative-leaning.