U.S. economic output rose at a surprisingly strong 4.2 percent annual rate in the fourth quarter of 1987, but spending by consumers fell sharply, the Commerce Department reported.

The result was a large buildup in business inventories, which will cause companies to curb output and jobs in months ahead, economists said. The figures almost certainly mean that the economy will undergo a major slowdown, they said, and some warned that the chances of a recession this year have increased.

For all of 1987, the economy expanded at a 3.8 percent pace, as measured by the growth in gross national product, adjusted for inflation, from the fourth quarter of 1986 to the fourth quarter of 1987.

The White House, which had predicted a more modest 3.2 percent growth rate for 1987, issued an upbeat statement on the report. "This indicates very little slippage in growth from the October drop in the stock market," presidential spokesman Marlin Fitzwater said. "The economy continues to perform with considerable strength."

But the report also contained bad news for the White House, which is extremely anxious to avoid a recession in the coming election year.

Consumer spending declined at a 3.8 percent annual rate, adjusted for inflation, in the October-to-December period, while businesses were piling up inventories. Economists said that the cut in consumption may have been attributable to factors other than the stock market's woes. But they said that in any event, many companies will curtail operations, cease hiring and even lay off some workers to bring production into line with sales during the first half of 1988.

"We've got too many inventories, too many goods sitting on the shelf," said David Wyss, chief financial economist at Data Resources, an economic consulting firm in Lexington, Mass. Businesses will stop ordering goods for a while, Wyss said, and "the odds are very good now that we could have at least one quarter of negative growth" in 1988. A recession is usually defined as two consecutive quarters in which GNP falls.

The report is likely to intensify concern within the administration that the Federal Reserve is keeping interest rates too high. Beryl W. Sprinkel, chairman of the Council of Economic Advisers, has been complaining privately that the Fed is keeping too tight a rein on the economy, and some other administration officials also are worried. A spokeswoman for Sprinkel said yesterday that he would not comment on the GNP figures.

Fed officials appeared unalarmed by yesterday's report, however. Vice Chairman Manuel Johnson said it isn't clear that the large increase in inventories poses a threat to the economy in early 1988. The situation "certainly bears watching," he told reporters after delivering a speech.

He also rejected the central argument advanced by Sprinkel that last year's slow growth in the money supply could kill the expansion. "I don't see that there is any risk from the money supply numbers," Johnson said.

The Commerce report showed that the surge in inventories was responsible for the $39.2 billion increase in inflation-adjusted GNP for the October-to-December period, more than making up for a 3.25 percent decline in spending by consumers and businesses -- excluding inventories. Consumer spending plunged by $24.1 billion in inflation-adjusted terms.

This means the economy ended last year "on a note of extreme imbalance" between the level of demand and supply, said Stephen Roach, senior economist at Morgan Stanley & Co. The decline in consumer spending last quarter "was steeper than any drop we had during the last recession," Roach said, reflecting "a dramatic downshift in consumer demand."

The report, which is preliminary and subject to revision next month, came a day after a more encouraging announcement by Commerce showing that factory orders for durable goods soared by more than 6.7 percent in December. Economists said that the inventory buildup last quarter evidently didn't affect orders for big-ticket items in December because much of the stockpiling was concentrated at the retail level.

But the inventory buildup is "starting to back up through the system" to the wholesale level, said Lawrence Chimerine, chairman of the WEFA Group, a consulting firm in Bala Cynwyd, Pa. If consumer spending drops again in the current quarter, Chimerine added, "you could see a recession sometime this year. My guess is we'll skirt through without it, but it's certainly possible."

The GNP figures did provide some cause for optimism. The report showed that the U.S. trade deficit narrowed in inflation-adjusted terms by $7.7 billion in the fourth quarter, with an increase in merchandise exports accounting for about one-third of the rise in inflation-adjusted GNP.

The figures confirm that "we have an export boom and an export-led economic expansion," said Robert Ortner, a Commerce undersecretary.

The report also provided fresh evidence that inflation remains subdued. A measure of inflation known as the GNP deflator rose at a 2.7 percent annual rate in the fourth quarter.