NEW YORK, AUG. 13 -- The Dow Jones industrial average, defying steep drops in stocks in Japan and Europe, rallied at the close today for a 30-point gain on the strength of late buying by computer-program traders.

Beyond its program-driven swings, the market was characterized by falling volume and cautious, if persistent, nibbling by bargain hunters, said traders and analysts. Investors remained extremely nervous about the Mideast crisis and its potential for undermining an already weak U.S. economy.

Stocks opened into a lethal environment in which long-term bond prices were down sharply, gold prices had topped $400 an ounce and Japan's Nikkei-225 index had plunged 4.2 percent at the close in Tokyo.

After initial program selling dropped the Dow by 31 points, methodical bargain hunting propped the Dow back to neutral. The actual cash buying, however, failed to move the Dow more than a point into the black, and prices trailed off mildly into midafternoon. Only in the last hour of trading did at least four waves of program buying send the Dow materially higher.

At the close, the Dow stood at 2746.78, up 30.20. Advancing stocks in the New York Stock Exchange, which trailed declines 4-to-9 in early trading, trailed by a narrow margin at the finish.

Big Board volume, which was unaffected by a massive power outage in New York's financial district, contracted to a light 122 million shares. It was by far the thinnest market since the invasion of Kuwait by Iraq on Aug. 2, seven trading days earlier.

Block trader John Burnett at Donaldson, Lufkin and Jenrette said, "We were watching an oversold market trying to rally. They got it down over 30 points on the Dow at the start, and when the selling stopped, the 'bargain-basement' people came in, and it was up from there," he said.

"But it's not what you'd call a broad-based rally," Burnett said. "The market's being held up by pockets of bargain hunting -- that's about it."

Among those pockets of strength at midafternoon -- beyond the precious metals issues, which continued to respond to gold prices at five-month highs -- were selected retail stores, computers, semiconductors, cosmetics, drugs, medical services and money-center banks -- even though financial-services stocks and insurance companies generally traded lower.

Among Dow components, while the initial decline was led by issues such as Boeing, Merck, Minnesota Mining, and International Paper, the last-hour rally was led by Eastman Kodak, up 2 1/2 at 43 1/2 at the close, Du Pont, up 1 1/8 at 38 5/8, IBM, up 1 3/4 at 103 3/4, Procter & Gamble, up 1 7/8 at 81 3/4, and early loser Merck, which rose 2 1/8 to 86 7/8. Of the prominent gainers, however, all five stocks are also components of the Major Market index of 20 stocks, a popular trading vehicle for index arbitrageurs.

The Dow transports rose 4.01 to 978.83, while the interest-sensitive utilities gained 0.88 to 203.97 despite a 13/32 drop in the U.S. 30-year Treasury bond as stocks closed.

Among broad stock indexes, primary measures fared better than secondary averages all day. At the close, the Standard & Poor's 500 was up 3.32 at 338.84, the NYSE Composite rose 0.02 at 184.17, the Value Line climbed 0.10 at 262.36 and the Nasdaq Composite was up 0.27 at 408.30.

The Amex Market Value remained off 1.32 at 338.00 due to the exchange's early afternoon close following a power outage.