Mark Esper, an Army veteran and former defense industry lobbyist, won Senate confirmation by a vote of 90-8 and was sworn in at the White House by Supreme Court Justice Samuel Alito in a ceremony attended by Trump and several members of Esper's family.
"He's going to be a great one," Trump said.
Esper's swearing-in ended the longest period the Pentagon has gone without a confirmed leader in its history.
The turmoil atop the Pentagon began when Mattis stepped down last New Year's Eve after a series of policy disputes with Trump. He offered to stay two more months to get a successor in place and ensure continuity, but Trump said no.
The president was high on Mattis at the start of his administration. He liked to call the retired Marine general "Mad Dog," but the affection waned and shortly before Mattis quit Trump referred to him as "sort of a Democrat."
Even with Esper now in charge, the problem of leadership instability at the Pentagon is not fully resolved. There still is no Senate-confirmed deputy secretary of defense, though David Norquist on Tuesday was nominated for the post and is scheduled to have a confirmation hearing Wednesday. Norquist has been filling in as deputy since January; his regular job is Pentagon budget chief.
The senior leadership vacancies increased again last week with the departure of David Trachtenberg, the Pentagon's second-ranking civilian policy official.
Beyond that, the No. 2-ranking military officer, Gen. Paul Selva, is retiring Friday as vice chairman of the Joint Chiefs of Staff. No Senate confirmation hearing has been set for the man picked by Trump to replace Selva: Gen. John Hyten, who has been commander of U.S. nuclear forces as head of U.S. Strategic Command.
A military officer has accused Hyten of sexual misconduct . An investigation found insufficient evidence to charge Hyten, but some members of Congress have raised questions about that process. It's unclear when or whether Hyten's nomination will proceed.
At his confirmation hearing on July 16, Esper promised that one of his first priorities would be to fix the problem of leadership vacancies.
"I need to staff up the top tier of the Pentagon soonest," he said.
Carl Tobias, a professor of law at the University of Richmond, said he believes that in the months since Mattis left, the Pentagon's sway within the administration has weakened.
"This seems to be the primary challenge that Esper confronts: regaining the power to set the Defense Department agenda and defend it by doing what is best for the nation and the world, not what advances the president's political agenda," Tobias said by email.
Esper had been the Army secretary when Mattis resigned in December. On Jan. 1, the deputy defense secretary, Patrick Shanahan, became the acting secretary. But after nearly six months as the fill-in, the former Boeing executive abruptly quit .
Esper then became the acting defense secretary, but once he was nominated last week, he had to step aside until after a Senate vote. So, for the past week, the Pentagon had been run by yet another fill-in: Navy Secretary Richard V. Spencer.
Esper, who has a wide range of experience in defense matters, including time on Capitol Hill as a congressional staff member, has said he intends to continue the Trump administration's focus on improving the combat preparedness of the military, nurturing security alliances around the world and reforming Pentagon business practices.
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 his former employer, Raytheon Co., for the duration of his time as defense secretary.
Democratic Rep. Adam Smith, chairman of the House Armed Services Committee, said he was encouraged by Esper's confirmation but worried by the continuing problem of vacancies in the Pentagon.
"The complex challenges that we face around the globe are too serious for key positions at the Department of Defense to remain transient," Smith said. "Instead, our country needs predictable leadership at the Pentagon, capable of withstanding internal political pressure in what has been a historically turbulent administration."
Esper was a lobbyist for Raytheon, a major defense contractor, for several years before becoming Army secretary. He told Warren that Defense Department ethics officials recommended he not make the recusal commitment she asked about, but pledged to abide by all ethics rules and regulations.
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.