WASHINGTON—U.S. Defense Secretary James Mattis warned North Korea in stark terms on Sunday that any attack on the U.S. or its allies would trigger a massive military response, in comments that came after a national-security briefing with President Donald Trump following Pyongyang’s sixth and most powerful nuclear test.

“We have many military options and the president wanted to be briefed on each one of them,” Mr. Mattis said in brief comments Sunday afternoon, accompanied by Gen. Joseph Dunford, chairman of the Joint Chiefs...