WASHINGTON — James N. Mattis, the retired Marine Corps general, told Congress on Thursday that President Vladimir V. Putin of Russia was trying to “break the North Atlantic alliance,” staking out a tougher stance on Russia during a confirmation hearing for defense secretary than his prospective commander in chief did on the campaign trail.

“I’m all for engagement, but we also have to recognize reality,” General Mattis told the Senate Armed Services Committee. “There’s a decreasing number of areas where we can engage cooperatively and increasing numbers of areas where we’re going to have to confront Russia.”

In a three-hour hearing, General Mattis argued for expanding the armed forces, improving the military’s readiness to go into battle on short notice and reinvigorating the North Atlantic Treaty Organization by maintaining a permanent armed American presence in Baltic nations to deter a Russian attack, among other steps.

“My view is that nations with allies thrive and nations without allies don’t,” General Mattis said.

Those remarks were a striking contrast to comments by President-elect Donald J. Trump during the campaign that American support for the alliance should be conditional on financial contributions by its members.