The US faced “growing threats from revisionist powers as different as China and Russia”, he said, unveiling the national defence strategy.
In an apparent reference to Russia, he warned against “threaten[ing] America’s experiment in democracy”.
“If you challenge us, it will be your longest and worst day,” he warned.
America has been gripped by ongoing investigations into alleged collusion between the Trump 2016 election campaign and Russia.
Speaking in Washington, Mr Mattis also appealed to Congress to fund the military adequately and refrain from “indiscriminate and automatic cuts” to the US federal budget.
President Donald Trump is seeking to boost defence spending by 10%, or $54bn (£43bn), in his proposed budget plan for this year, and hopes to recoup that sum through deep cuts elsewhere, including to foreign aid.
The publication of the Trump administration’s new National Defense Strategy signals an important shift in Washington’s priorities.
For almost two decades – ever since the attacks of 9/11 – America’s military focus has been on fighting terrorism, with counter-insurgency campaigns in Afghanistan, Iraq and Syria.
But now there is to be a renewed emphasis on inter-state strategic competition – matching so-called peer competitors like Russia and China.
US Defence Secretary James Mattis is right when he says that Washington’s competitive military edge is fast eroding. There needs to be investment in a range of new technologies that might provide the edge on a future battlefield.
But it is not simply a matter of spending more money. He pointed to the difficulty of passing budgets on Capitol Hill over successive years which, he said, had done more damage to US military readiness than any enemy in the field.
This is the first time the defence policies of the Trump administration have been spelled out in one place.
The threats listed are the same as under the Obama administration but the order of priority is different.
Formerly, jihadist militant groups like Islamic State or al-Qaeda were the focus but latterly America’s former Cold War opponents, Russia and China, have reasserted themselves strategically.
“We face growing threats from revisionist powers as different as China and Russia, nations that seek to create a world consistent with their authoritarian models,” Mr Mattis said.
The three great nuclear powers have posed a permanent existential threat to each other since Cold War days. (Courtesy BBC)