Overcoming months of uncertainty over the direction of the economy and inflation, the Dow Jones industrial

average Thursday topped the 4,000 mark for the first time in history.The bellwether index of 30 blue-chip stocks hit 4,000.30 at 9:58 a.m. EST, about a half hour after the start of trading on the New York Stock Exchange.

The milestone was achieved amid optimism in the nation's financial markets generated by indications Wednesday from Federal Reserve Chairman Alan Greenspan that the central bank may be finished raising interest rates.

The Dow, which gained 9.08 points Wednesday began soaring Thursday morning. After breaching the historic mark, the average briefly fell back but then traded higher, reaching 4,015.44 in late afternoon trading. With less than an hour of trading left, the Dow was at 4,000.64 up 27.59 for the day.

"It's fabulous," said Hugh Johnson, chief market strategist at First Albany Corp., who nonetheless cautioned that the rally could stall.

Added John Burnett, a stock trader at Donaldson, Lufkin & Jenrette Securities: "Greenspan's comments yesterday have got everybody enthused. How long the enthusiasm will last, I don't know."

Greenspan indicated Thursday that the central bank stands ready to cut interest rates if the hoped-for budget deficit reduction under the Republican Congress hurts the economy.

"It may - and I use the word may - have a short-term effect," Greenspan told a House Banking subcommittee. "And if that occurs and that affects . . . the things that the Federal Reserve looks at in formulating policy, we obviously will respond to that."

The New York Stock Exchange composite index was ahead 1.50 to 264.54, while Standard & Poor's 500-stock index was up 2.56 to 487.63 - slightly above its record closing high of 485.22 that was set Feb. 16.

Volume was about 327,040,000 shares, compared with 277,810,000 in the same period Wednesday.

Prices were marginally higher on the American Stock Exchange and modestly higher on the Nasdaq Stock Market.