WASHINGTON (AP) — Retired Gen. James Mattis on Thursday cruised toward likely confirmation as Donald Trump's defense secretary, easily prevailing in a Senate vote granting him an exemption to run the Pentagon as a recently retired officer. At his confirmation hearing, he called Russia the nation's No. 1 security threat, accusing its leader of trying to "break" NATO.

The Senate voted 81-17 to approve legislation overriding a prohibition against former U.S. service members who have been out of uniform less than seven years from holding the Defense Department's top job. The restriction is meant to preserve civilian control of the military. The House Armed Services Committee backed the waiver in a 34-28 vote; the full House will take up the matter Friday.

Mattis, 66, spent four decades in uniform, retiring in 2013 with a reputation as an effective combat leader and an astute strategist. Separate from the override legislation, the Senate will vote later on Mattis' nomination and will almost certainly confirm him.

The only other exception to the seven-year rule was made for the legendary George Marshall in 1950, the year Mattis was born. Even some of Trump's strongest critics have supported the waiver for Mattis, arguing that his experience and temperament can serve as a steadying influence on a new president with no experience in national security.

It was unclear if President Barack Obama would sign the legislation allowing Mattis to take up the post, or if it would fall to Trump after his inauguration.

At an uncontentious confirmation hearing, Mattis sketched an international security scene dominated by dark images of an aggressive Russia, resurgent China and violent Mideast. He described Iran as a major destabilizing force, called North Korea a potential nuclear threat and said the U.S. military needs to grow larger and readier 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 strikingly dissonant with 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.

Of Putin, said Mattis, a former NATO military leader: "He is trying to break the North Atlantic alliance."

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.

As he spoke, Trump's choice to run the CIA, Rep. Mike Pompeo of Kansas, sided with intelligence officials who claim the Kremlin was behind the election cyberattacks, adopting a similarly tough stand against Russia in his confirmation hearing. Ties between the former Cold War foes also have been strained by Syria's civil war.

Mattis faced no hostile questions from Republicans or Democrats, receiving bipartisan praise for his reputation as a straight-talking, well-read man of integrity and intelligence.

William Cohen, a defense secretary for Democratic President Bill Clinton, introduced Mattis as a "humble man with very little to be humble about."

"He's a man of thought as well as action," Cohen said.

Mattis said the world order is under "the biggest attack since World War II," blaming Russia, China and international terrorist organizations for its destabilization.

On cyberattacks, Mattis noted that wars often are started by miscalculation. He said the U.S. needs to set clear boundaries so that adversaries know what the U.S. will not tolerate.

In prepared testimony, Mattis said he understands his role as the Defense Department's civilian leader would be different "in essence and in substance" from his four decades in uniform. He called civilian control "a fundamental tenet of the American military tradition."