Defense Secretary Jim Mattis

Defense Secretary Jim Mattis made an unannounced visit to the US naval base at Guantanamo Bay on Thursday, the Pentagon said, marking his first such visit there.

"Secretary Mattis is currently visiting with troops at Guantanamo Bay for the holidays to thank them for their service," Pentagon spokesman Major Ben Sakrisson said.

Officials said Mattis would not visit the base's notorious detention center, which still houses inmates captured after the September 11, 2001 attacks.

Attorney General Jeff Sessions visited Guantanamo in July, and Mattis is the first Pentagon chief to visit Guantanamo since Donald Rumsfeld in the early 2000s.

While his trip was focused on holiday greetings to the more than 5,000 troops stationed on the base at the eastern tip of Cuba, Mattis's visit highlights the ongoing uncertainty around what will happen to the prison.

At the height of its operations after 9/11, the prison held 780 people detained mostly for their alleged ties to Al-Qaeda and the Taliban.

Since then, hundreds have been transferred back to their home countries or other places.

But some of the most notorious inmates, including several alleged 9/11 co-conspirators, including accused mastermind Khalid Sheikh Mohammed, are still awaiting trial.

And of the 41 inmates remaining at Guantanamo, about 26 are trapped in legal purgatory.

These so-called "forever prisoners" have never been charged -- yet they have been deemed too dangerous to release.

Barack Obama tried throughout his presidency to shutter the detention center but was rebuffed by Republican opponents.

As a candidate, Donald Trump said he wanted to fill it with "bad dudes."

Last month, Trump suggested that the man accused of carrying out a deadly truck attack in New York could be sent to Guantanamo, but he later backed off the idea.