“If we have to close down our government, we’re building that wall.”

So proclaimed President Trump at a rally in Arizona on Tuesday, raising the specter of a federal government shutdown if Congress fails to provide the money to put up a wall between Mexico and the United States.

And with those words, the president managed to rattle investors in two big financial markets — United States Treasuries and stocks.

In recent years, government shutdowns have become so common that markets have either embraced them or shrugged them off. But as investors absorb the possibility of a closure this fall, market tremors are likely to intensify, experts say. The past will not necessarily be prologue this time around.

That’s the view of Isaac Boltansky, director of policy research at Compass Point Research & Trading in Washington. Noting that during the past three shutdowns, the stock market was unfazed by the political gamesmanship, Mr. Boltansky said, “I think this time will be worse because of the uncertainty from President Trump.”