Congress is sending the White House a bill to let retired Marine Gen. James Mattis run the Pentagon in the Trump administration.
The House passed the bill on a vote of 268-151.
A White House spokesman said President Barack Obama would sign the bill if Congress passed it before he leaves office.
The measure grants a one-time exception for Mattis from a law that bars former service members who have been out of uniform for less than seven years from holding the top Pentagon job.
The restriction is meant to preserve civilian control of the military. The 66-year-old Mattis retired from the Marine Corps in 2013.
The Senate overwhelmingly cleared the bill on Thursday.
Mattis faced no hostile questions during his confirmation hearing. He called Russia the nation's No. 1 security threat and accused its leader, President Vladimir Putin, of trying to "break" NATO.
He described Iran as a major destabilizing force, called North Korea a potential nuclear threat and said the U.S. military needs to be larger and more ready for combat.
"We see each day a world awash in change," Mattis said. "Our country is still at war in Afghanistan and our troops are fighting against ISIS and other terrorist groups in the Middle East and elsewhere. Russia is raising grave concerns on several fronts, and China is shredding trust along its periphery."
Mattis portrayed Russia as an adversary and said the history of U.S.-Russian relations is not encouraging.
"I have very modest expectations for areas of cooperation with Mr. Putin," he said, delivering an assessment very different from that of his potential commander in chief. Trump has repeatedly praised Putin, even as U.S. intelligence agencies have accused the Russian leader of orchestrating a campaign of interference in the 2016 U.S. election.
"He is trying to break the North Atlantic alliance," Mattis said of Putin.
He said he has explained to Trump his views on Russia, which include a deep worry that Moscow is determined to use intimidation and nuclear threats to create a sphere of unstable states on its periphery.
Mattis, who has served in numerous senior military positions, including commander of U.S. Central Command in charge of all American forces in the Middle East, said he supports the Obama administration's moves to reassure European allies after Moscow's annexation of Ukraine's Crimea region and military activity in eastern Ukraine.
While the U.S. should remain open to working with Russia, Mattis said, the prospects for cooperation were narrowing even as areas of disagreement grow larger.