President Trump took part in the swearing-in ceremony for new Defense Secretary Mark Esper on Thursday — hailing his experience in the military and defense industry.

“I have absolute confidence that Mark will ensure that our incredible military is fully prepared to deter conflict and defeat any foe,” Trump said under sunny skies outside the Pentagon after a military band played “The Star-Spangled Banner.”

The president then touted defense spending hikes that he has supported on his watch, asserting that the US was rebuilding its military after it became depleted fighting long wars in Iraq and Afghanistan.

“We have rebuilt things that nobody ever even thought of rebuilding,” he said.

And he invoked the memory of the 9/11 attacks on the Pentagon, where 125 military personnel and civilians were killed when a hijacked jet slammed into the landmark building.

“We vow to do whatever it takes to protect our homeland from the threat of radical Islamic terrorism,” the commander-in-chief said.

Esper, 55, a West Point grad and former Raytheon lobbyist, praised the Pentagon’s workers for their “spirit and dedication.”

“I want to thank the great patriots, military and civilian alike, who come to work here and focus on one thing, supporting the 2 million soldiers, sailors, airmen and Marines who sacrifice and serve in defense of our great nation. They represent America’s best and I am proud to serve alongside them.”

The Senate on Tuesday confirmed Esper in a bipartisan 90-8 vote, a margin that Trump at the ceremony joked made him wary of the new defense chief as a possible rival.

The confirmation ended a record-long seven months that the Pentagon went without a Senate-confirmed leader — amid escalating tensions with Venezuela and Iran.

The post had been vacant since former Secretary Jim Mattis resigned on New Year’s Eve to protest Trump’s since-reversed decision to withdraw troops from Syria and wariness of NATO and international alliances.

Esper was one of three people who served as acting defense secretary in the time since.

Esper, who had served as Army secretary since late 2017, previously worked on Capitol Hill as a senior Republican staffer, in top positions at the Pentagon and at the conservative Heritage Foundation.

He also served for over a decade in the Army, when he participated in the Gulf War.

All eight senators who voted against Esper’s nomination are Democrats. They include Sen. Elizabeth Warren of Massachusetts, a candidate for the Democratic presidential nomination, who has sharply criticized Esper for declining to recuse himself from all matters involving Raytheon for the duration of his time as defense secretary.