U.S. President Donald Trump's warning to North Korea and Pyongyang's threat of possible armed retaliation drove investors out of stocks and other risky assets on Wednesday and into textbook safe-havens like gold and Treasuries.

Trump's remarks on Tuesday that North Korea would face "fire and fury like the world has never seen" weighed on Wall Street and drove up the VIX "fear gauge", or the cost of protection against a drop in the S&P 500.

The VIX rose further on Wednesday, as far as 12.63, its highest in more than a month.

The Korean People's Army said on Wednesday it was "carefully examining" plans for a missile attack on the U.S. Pacific territory of Guam, which has a large U.S. military base. U.S. Defense Secretary Jim Mattis told Pyongyang it should stop any actions that would lead to the "end of its regime and the destruction of its people."

But while investors appeared to favor safe-haven assets, some bargain seekers helped Wall Street's three major indexes pare losses.

"Geopolitics splashed cold water on the markets," said JJ Kinahan, chief strategist at TD Ameritrade.

"There's uncertainty and caution as investors nervously eye the next foreign policy moves."

Trump tweeted on Wednesday about the strength of the American nuclear arsenal, but expressed hope it would not need to be used. U.S. Secretary of State Rex Tillerson said he did not believe there was an imminent threat.

U.S. stocks closed barely down on Wednesday as the Dow Jones Industrial Average fell 36.64 points, or 0.17 per cent, to 22,048.7, the S&P 500 lost 0.9 points, or 0.04 per cent, to 2,474.02 and the Nasdaq Composite dropped 18.13 points, or 0.28 per cent, to 6,352.33.

The S&P had been down 0.52 per cent at its session low.