Reports of the economic expansion’s death appear to have been greatly exaggerated.

The United States economy surged unexpectedly in the first quarter, the Commerce Department said Friday, allaying concern that financial-market volatility and a prolonged government shutdown would cause a slump.

That is good news for President Trump, who is counting on a strong economy to improve his chances for re-election. With investors and consumers alike showing renewed optimism, it is now all but certain that the decade-long expansion will become the longest on record later this year.

“The angst has settled, and the economy has come back,” said Ben Herzon , an economist with Macroeconomic Advisers, a forecasting firm. “I just can’t point to anything now that’s going to push us into recession.”

Gross domestic product, the broadest measure of goods and services produced in the economy, rose at a 3.2 percent annual rate in the first three months of the year. That is faster than most economists expected, and far better than the dour outlook of early this year, when many forecast that the figure could fall below 1 percent.