Stocks fell on Friday as investors feared President Donald Trump's surprise threat of tariffs on all Mexico imports, amid a worsening trade war with China, could risk sending the U.S. economy into a recession.

The Dow Jones Industrial Average closed 354.84 points lower at 24,815.04, while the slid 1.3% to 2,752.06. The Nasdaq Composite dropped 1.5% 7,453.15. The S&P 500 ended the month down 6.6% as volatility spiked after trade talks fell apart with China and rhetoric on both sides worsened in May.

"President Trump's latest trade bombshell … might turn out to be a short-lived threat that is quickly defused by commitments on border security, but it nonetheless looks damaging at a number of levels," Krishna Guha, head of global policy and central bank strategy at Evercore ISI, wrote in a note. "At the big picture level, it suggests that Trump trade policy might well mean a permanent state of endemic uncertainty and instability in the global trading system not simply a hard-headed sequential re-set of prior arrangements that started with Mexico and proceeds via China to Europe and Japan."

Friday's declines added to a torrid week and month for stocks. The Dow dropped 3% this week and notched its sixth straight weekly loss. That's the longest weekly losing streak for the Dow since 2011. The S&P 500 and Nasdaq posted their fourth straight weekly loss. The major indexes also snapped a four-month winning streak.

Shares of GM dropped 4.25% on Friday. Ford lost 2.3%. Both have significant production in Mexico that could be subject to tariffs. Shares of railroads Kansas City Southern and Union Pacific also fell 4.5% and 2%, respectively. Fiat Chrysler closed 5.8% lower. Corona and Modelo beer maker Constellation Brands slid 5.9%.

The closely watched 10-year Treasury yield dropped to lows not seen since 2017. The U.S. benchmark was yielding 2.13% Friday. It was above 2.5% at the beginning of the month. Mexico's currency, the peso, tanked against the dollar by more than 2% to trade at 19.62 per dollar.

On Thursday evening, Trump announced the U.S. would impose a 5% tariff on all Mexican imports from June 10 until illegal immigration across the southern border was stopped.

Trump Tweet

The White House added in a statement that tariffs would be raised if the immigration issue persisted, with the charges set to increase even further if Mexico fails to take "dramatic action" to reduce or eliminate the problem.

Mexico is one of the U.S. largest trade partners. The U.S. imports every year billions of dollars worth of chemicals, transportation equipment and other goods from Mexico.

The news regarding U.S. tariffs on Mexican goods comes as the U.S. tries to work out a trade deal with China. Washington and Beijing have imposed tariffs on billions of dollars' worth of one another's goods since the start of 2018, battering financial markets and souring business and consumer sentiment.

Earlier this month, the two countries hiked tariffs on their goods, sparking a sell-off in equities.

The "worst case scenario is foreign governments (China/Mexico) simply wait Trump out given we're 19 months from an election," wrote Tom Essaye of The Sevens Report. "In that outcome, there is no China trade deal and tariffs (Chinese and Mexican) act as an anchor on global growth and market sentiment for 18 months, increasing the chances of a recession."

The biggest Chinese newspaper explicitly warned the U.S. on Wednesday that China would be prepared to cut off rare earth minerals as a countermeasure. Chinese Vice Foreign Minister Zhang Hanhui then said Thursday that provoking trade disputes amounted to "naked economic terrorism."

Not helping things, the trade war appears to be dragging down the Chinese economy. The country's manufacturing activity contracted more than expected in the month of May, China government data out overnight showed. The official manufacturing Purchasing Managers' Index (PMI) for May was 49.4, down from April's reading of 50.1. PMI readings below 50 signal contraction.

"The best thing we can do for our clients is stay balanced and diversified," said John Augustine, chief investment officer at Huntington Private Bank. "That's how we've been navigating the tweet-headline environment. We just don't know how these trade policy issues are going to turn out."

— CNBC's Joanna Tan, Eustance Huang, Sam Meredith and John Melloy contributed to this report.