A late rally saved the stock market from a second day of losses that began after reports showed an abrupt decline in consumer confidence and slowing economic growth in the Middle West.

The Dow Jones industrial average, which had traded down 20 to 30 points for most of the day, closed more than 51 points higher at 10,173.92, after climbing steadily in the final 40 minutes of trading.

The Standard & Poor's 500 stock index gained five points to 1,104.24.

Turning positive only in the final five minutes of trading, the Nasdaq Stock Market composite index advanced less than two points to 1,838.10.

Tech stocks were so weak today that even Apple Computer had trouble advancing after unveiling its newest, coolest computer -- with all the components built into the flat panel display. Merrill Lynch immediately boosted Apple to "buy" after the debut of the two-inch thick I-Mac, but the stock gained only 37 cents to $34.49.

The day's hottest stock was Six Flags Inc., whose shares jumped 25 percent after the disclosure of big investments by Washington Redskins owner Daniel Snyder and Microsoft founder Bill Gates.

The Wall Street Journal broke the story that Snyder had spent $34 million to accumulate 9 percent of the stock, becoming the third largest stockholder of the troubled amusement park chain.

Turns out the second largest stockholder is Gates, who holds about 12 percent of the stock and like Snyder thinks the company is badly managed. Gates plans to seek representation on the Six Flags board, a spokesman said today.

The names Gates and Snyder were all some traders had to hear. The stock, which had fallen more than 50 percent this summer, jumped $1.11 a share to $5.57.

Investor worries about the economy increased this morning with the releases of reports by the Conference Board and the National Association of Purchasing Management--Chicago.

The Chicago group's regional business barometer fell from 64.7 to 57.3.

The Conference Board's consumer confidence index dropped to 98.2 from 105.77.

Both reinforced the impression that the economy is weakening but were in line with other economic data. The real measure of consumer confidence will be seen when major chain stores report their August sales later this week. What consumer do at the checkout is more important than what they tell pollsters, analysts say.