He said the regime would be in trouble “like few nations have ever been” if they do not “get their act together”.

Tensions have escalated rapidly in recent weeks after North Korea tested two intercontinental ballistic missiles in July.

It was further angered by a subsequent UN decision to increase economic sanctions against it.

North Korea has said it will finalise a plan in days to fire medium-to-long-range rockets towards Guam, the small Pacific island where US strategic bombers are based, along with more than 160,000 US citizens.

There has been no indication that any attack on the Pacific island is imminent.

Mr Mattis, speaking in California late on Thursday, said it was his job as defence secretary to be ready for conflict.

But he said the diplomatic effort, under Secretary of State Rex Tillerson and UN Ambassador Nikki Haley, “has diplomatic traction, it is gaining diplomatic results”.

“The tragedy of war is well enough known,” he said. “It doesn’t need another characterisation beyond the fact that it would be catastrophic.”

When asked about US military plans for a potential conflict, Mr Mattis said the country was ready, but “I don’t tell the enemy in advance what I’m going to do”.

Speaking on Thursday at his golf club in Bedminster, New Jersey, Mr Trump suggested his own statements on North Korea – where he threatened them with “fire and fury the likes of which the world has never seen” – had not been tough enough.

He also railed against previous US administrations for being too weak on North Korea and again chided the North’s closest ally, China, saying it could do “a lot more”.

He said: “I will tell you this, if North Korea does anything in terms of even thinking about attack of anybody that we love or we represent or our allies or us they can be very, very nervous.

“I’ll tell you why… because things will happen to them like they never thought possible.

“I will tell you this, North Korea better get their act together or they’re gonna be in trouble like few nations have ever been.”