Washington (CNN) President-elect Donald Trump's selection to be defense secretary emerged from his confirmation hearing Thursday with seemingly broad support, after he took a strong posture against Russian President Vladimir Putin and answered tough questions on women and gays in combat.

Ret. Gen. James Mattis also cleared one early procedural hurdle in his confirmation as the Senate voted overwhelmingly in favor of giving him a waiver to a law barring military officials from becoming defense secretary within seven years of their military service.

The Senate's 81-17 vote, following the Senate Armed Services Committee's bipartisan 24-3 vote, also signaled Mattis would likely face little opposition to his confirmation.

Much of Mattis' hearing focused on areas where Trump and Mattis might diverge in views.

At the top of the hearing, Mattis took a hard stance against Russia and Putin in answering a question from anti-Russia hawk, Senate Armed Services Committee Chairman John McCain.

The topic has been one of the greatest sources of Republican criticism of President-elect Donald Trump, who has repeatedly spoken favorably about Putin and for months denied Russia's role in a hacking and misinformation campaign designed to influence the election.

"I've watched three presidents commit themselves to new relationships with Vladimir Putin. All three have been an abysmal failure," McCain said, asking Mattis what he would do.

"I think right now the most important thing is that we recognize the reality of what we deal with (in) Mr. Putin," Mattis said. "We recognize that he is trying to break the North Atlantic alliance, and that we take the steps, the integrated steps, diplomatic, economic, military and the alliance steps, working with our allies to defend ourselves where we must."

He identified Russian aggression, terrorism and Chinese actions in the South China Sea as the biggest security issues since WWII.

"I think deterrence is critical right now, sir, absolutely, and that requires a strong military," Mattis said, arguing that the US military is not robust enough right now.

He answered similar questions about Moscow from the top Democrat on the committee, Sen. Jack Reed of Rhode Island.

"I'm all for engagement, but we also have to recognize reality and what Russia is up to," Mattis said. "There's a decreasing number of areas where we can engage cooperatively and an increasing number of areas where we're going to have to confront Russia."

The topic of NATO was also raised by multiple senators. On the campaign trail, Trump indicated he may reconsider aspects of the US alliance with NATO, alarming lawmakers on both sides of the aisle.

Mattis, a former supreme allied commander of NATO, voiced unequivocal support for the alliance and said he had said as much to Trump.

"NATO, from my perspective ... is the most successful military alliance certainly in modern world history, probably ever," Mattis said. "I have had discussions with him on this issue. He has shown himself open, even to the point of asking more questions and going deeper into the issue about why I feel so strongly."

Questions on women, gays in combat

Later, Mattis was peppered with questions about women and gays in the military from several lawmakers.

Sen. Kirsten Gillibrand, a New York Democrat who has been outspoken on the issue of women in the military and military sexual assault, engaged in a lengthy back-and-forth with Mattis about his position on women and gays in combat -- asking him if he would roll back gains on that front.

Mattis repeatedly dodged direct questions about whether he opposes women serving in combat positions or gays in the military, despite Gillibrand reading back his past comments to him.

In one case, she quoted a passage in Mattis' book, "Warriors and Citizens," in which he decried the military being subject to societal pressure on causes like women in combat.

"We fear that an uninformed public is permitting political leaders to impose an accretion of social conventions that are diminishing the combat power of our military," he and his co-author wrote, as Gillibrand read in the hearing.

At the hearing, Mattis responded, "If someone brings me a problem, I'll look at it. But I'm not looking for problems."

He continued, "My belief is we have to stay focused on a military so lethal that on a battlefield it will be an enemy's longest day and worst day when they run into that force. ... My concern is with the readiness of the force."

He indicated he would come in with a predisposition to not re-open past decisions.

"I've never come into any job with an agenda, a pre-formed agenda of changing anything. I come in assuming the people before me deserve respect for the job they did and the decisions they made," Mattis said.

His answers also left wiggle room that he could roll back both women in all combat positions and gays serving in the military.

Mattis did not answer Gillibrand's question about whether he believes the policies undermine the readiness of the force.

"Frankly, senator, I've never cared much about two consenting adults and who they go to bed with," he said.

Hawaii Democrat Sen. Mazie Hirono picked up on Gillibrand's thread, asking Mattis if there is "anything innate" in women and gays that would undercut their ability to be part of a lethal force. Mattis simply answered, "No."

Mattis also told Missouri Democrat Sen. Claire McCaskill that as long as readiness standards are met, he will not object.

"The standards are the standards and when people meet the standards, that's the end of discussion on that," Mattis said. "The reason we're able to maintain an all-volunteer force with very, very high recruiting standards is because we go to males and females. ... Where they can best serve, that's where they go."

Mattis facing favorable winds

Mattis is expected to have the votes to be confirmed, as Republicans have a majority in the Senate.

An early indicator of Mattis' favor was the overwhelming vote for his waiver.

Some of the Democratic lawmakers on the panel foreshadowed their support for the waiver -- saying in fact they backed Mattis as defense secretary precisely as a check on Trump on use of military force.

"Let me say very bluntly: If there were ever a case for a waiver of that principle, it is you at this moment in our history," said Connecticut Democrat Sen. Richard Blumenthal. "Your appreciation for the costs of war in blood, treasure and lives, and the impact on veterans afterward, will enable you to be a check on rash and potentially ill-considered use of military force by a President-elect who perhaps lacks that same appreciation."

Massachusetts Democrat Elizabeth Warren seemed pleased when she asked Mattis under what circumstances he would be forceful in expressing his views, even when they diverged with the President.

"On every circumstance, Senator," Mattis said.

Nevertheless, Warren and Blumenthal both voted against the waiver for Mattis in committee.

In their opening statements, the top committee Republican and Democrat were both generally favorable to Mattis.

"Current law would bar him from serving as secretary of defense for three more years. While I strongly support retaining the law, I also believe that our nation needs Gen. Mattis' service more than ever," said McCain.

Reed trained his concerns mainly on Trump, criticizing Putin and praising past statements from Mattis saying the Iran nuclear deal should remain in place unless violated.

"You will help oversee national security policy for a president who lacks foreign policy and defense experience, and whose temperament is far different from prior presidents," Reed said. "I think many Americans, and many in this body, on both sides of the aisle, are rightly concerned about how he may respond when he is tested by Russia, Iran, North Korea, and other transnational threats such as cyber."

The retired four-star general is a bachelor who spent most of his adult life in the Marines. He served in the first Gulf War and Afghanistan in addition to his positions atop NATO and US Central Command, which is in charge of the US military in the Middle East.

While his friends don't call him "Mad Dog," he has earned the nickname in part because of some of his frank comments on the violence that combat sometimes requires.

"Be polite, be professional, but have a plan to kill everybody you meet," he would tell his Marines in Iraq, according to Thomas Ricks' book "Fiasco." He also drew criticism for saying in 2005, "It's fun to shoot some people."

Of the nickname, which was brought up by New Mexico Democratic Sen. Martin Heinrich, Mattis said it was misnomer.

"Senator, first I assure you that that nickname was given to me by the press, and some of you may have experienced similar occasions with the press where perhaps they didn't get it quite right," Mattis said.