SEOUL, South Korea — Defense Secretary Jim Mattis on Saturday accused North Korea of accelerating the threat of nuclear war through its series of nuclear and ballistic missile tests.

Wrapping up a two-day visit to Seoul that is serving as a precursor to a visit next month by President Trump, Mr. Mattis characterized Pyongyang’s behavior as threatening and said that the United States would do everything in its power to protect its allies in the region.

In remarks at the South Korean Ministry of National Defense, Mr. Mattis said the military and diplomatic relationship between Washington and Seoul has taken on a “new urgency.” He accused Pyongyang of accelerating the “threat that it poses to its neighbors and the world through its illegal and unnecessary missile and nuclear weapons program,” and added that North Korea was engaging in “outlaw behavior, threatening behavior.”

He made no mention of Mr. Trump’s own threats, including one in which the American president has said that North Korea’s leaders “won’t be around much longer,” which Pyongyang called a declaration of war.