U.S. Secretary of Defense Jim Mattis on Saturday strongly warned North Korea of a "massive military response" if it attacks on the United States or its allies.

"Make no mistake - any attack on the United States, or our allies, will be defeated," he said after talks with South Korean Defense Minister Song Young Moo.

"Any use of nuclear weapons will be met with a massive military response, effective and overwhelming," Mattis told reporters at a joint press conference with Song.

Their talks, known as the annual Security Consultative Meeting between the two allies, came at a time when tensions have sharply escalated on the peninsula over North Korea's nuclear and missile threats, marked by a war of words between U.S. President Donald Trump and North Korean leader Kim Jong Un.

Trump is slated to visit the South early next month on his first trip to Asia.

"Diplomacy remains our preferred course of action, but as I repeatedly emphasized, diplomats are most effective when backed by credible military force in this sort of situation," Mattis said.

On his part, Song said he and Mattis agreed to cooperate in expanding rotational deployment of U.S. strategic assets such as aircraft carriers, nuclear-powered submarines and bombers in South Korea, and also various deterrence measures to better counter North Korea's threats.

"The U.S. and South Korea strongly condemned North Korea's reckless provocative behaviors and agreed to back up diplomatic efforts by a strong combined alliance," Song said.

The two defense chiefs also agreed to consider the timing and conditions in resolving the issue of South Korea's gaining operational control at an early date.

Under the current arrangement, an American general has control over military operations in South Korea. South Korea has tried to regain operational control, but it has been indefinitely postponed due to North Korea's increasing military threats.

Mattis, who arrived in South Korea on Friday for a two-day visit, headed first to the tense border-crossing point north of Seoul, accompanied by Song.

"As Secretary of State (Rex) Tillerson has made clear, our goal is not war but rather the complete, verifiable and irreversible denuclearization of the Korean Peninsula," Mattis said, reading out a brief statement in the truce village of Panmunjeom.