Wall Street tried to demonstrate today that when worries about the economy fade, events in Iraq aren't out of control and the energy market is stable, the stock market can do pretty well.

It worked for about four and a half hours.

Then a report reached Wall Street that 40 people had been killed in Iraq when U.S. forces inadvertently attacked a wedding celebration and that was the end of business as usual.

After being up more than 100 points for most of the day, the Dow Jones industrial average went into a dive that wiped out all those gains and left the index down 31 points at 9,937.71.

The mid-day advance of the Standard & Poor's 500 stock index also was wiped out in the last hour and a half of trading, leaving the S&P off 3 at 1,088.68.

Hanging on by its fingernails, the Nasdaq Stock Market composite index managed to end the session up a fraction of a point at 1,898.17 after being up more than 35 points earlier in the day.

Stocks opened up for the second day in a row as investors focused on reports that computer and printer maker Hewlett Packard is raising its sales and profit forecast for the rest of the year after having an unexpectedly strong quarter.

HP's stock climbed almost 4 percent, the biggest percentage gain among the 30 stocks in the Dow Jones industrial average.

The response to HP's optimistic assessment of business prospects in the months ahead was a welcome contrast to what's happened several times recently, when evidence of strengthening business was overwhelmed by worries about violence in the Middle East or some other external disturbance. The afternoon retreat took back about one-third of what HP had gained earlier and left 20 of the Dow stocks down for the say.

Wall Street showed little reaction to another up day in the energy futures market. Crude oil prices -- which had slipped Tuesday -- eased back up and gasoline futures resumed their climb after the latest government report on gasoline and crude oil stockpiles. It showed the supply of gasoline increasing slightly, but the amount of crude available contracting.

Although gasoline and crude oil prices climbed a bit today, they did not return to the 20-year-record highs hit on Monday.

The upward pressure on gasoline and oil prices has been eased by talk that Saudi Arabia plans to begin pumping more oil. The OPEC oil ministers meet this weekend to discuss Saudi suggestions that producers ought to put out more product to bring down prices that are threatening economic growth in some countries.

The damage done by higher fuel prices was emphasized today by Gerard J. Arpey, chief executive of American Airlines. At the company's annual meeting, he said jet fuel expenses have jumped 25 percent over last year, and American will try to raise fares to make up for it.