The war of words between North Korea and the United States had many traders on edge Wednesday. But investors in defense stocks were profiting even as the broader market fell.

Shares of several companies that have big contracts with the U.S. military rose after President Trump warned that North Korea would face "fire and fury" if it did not back down from threats to use nuclear weapons against the U.S.

Shares of Lockheed Martin (LMT), Raytheon (RTN), Northrop Grumman (NOC) and L3 Technologies (LLL) hit record highs Wednesday.

The defense sector has been a big market winner during the past few months. The iShares U.S. Aerospace & Defense ETF (ITA) is up 30% since the election.

Many investors felt that defense stocks were great buys even before Trump's win.

Related: Global markets wobble after Trump issues warning to North Korea

That's because his challenger Hillary Clinton was also viewed as being "hawkish" on defense -- particularly when compared with President Obama -- and would have advocated for more defense spending.

But this new round of saber rattling from both North Korea and President Trump ups the ante.

Trump touted the modernization of America's own nuclear weapons in two tweets Wednesday morning but added that he hoped the U.S. would never need to use them.

My first order as President was to renovate and modernize our nuclear arsenal. It is now far stronger and more powerful than ever before.... — Donald J. Trump (@realDonaldTrump) August 9, 2017

...Hopefully we will never have to use this power, but there will never be a time that we are not the most powerful nation in the world! — Donald J. Trump (@realDonaldTrump) August 9, 2017

Kevin Miller, CEO and portfolio manager of the E-Valuator Funds, said his firm has invested more heavily in mutual funds that have increased their investment in defense stocks lately. But, he said the decision wasn't tied to North Korea as much as the possibility of other global conflicts.

"We live in a troubled world. Don't doubt that Iran is watching how things play out with North Korea," Miller said. "There is always going to be some hot spot around the globe."