WASHINGTON — The United States is switching its priority to countering Chinese and Russian military might after almost two decades of focusing on the fight against terrorism, Defense Secretary Jim Mattis said Friday, unveiling a national defense strategy that Pentagon officials say will provide a blueprint for years to come.

The new strategy echoes — on paper, if not in tone — a national security blueprint offered last month in which President Trump described rising threats to the United States from an emboldened Russia and China, as well as from what was described as rogue governments like North Korea and Iran.

But where Mr. Trump struck a campaign tone during the unveiling of his national security strategy, with references to building a wall along the southern border with Mexico, Mr. Mattis took a more sober route by sticking to the more traditional intellectual framework that has accompanied foreign policy doctrines of past administrations.

Drawing inspiration from Winston Churchill, who once said that the only thing harder than fighting with allies is fighting without them, Mr. Mattis said that the United States must strengthen its alliances with other powers.