NEW YORK, JULY 31 -- The Dow Jones industrial average closed down 12 points today after a late bout of program selling swept the Dow down 27 points to 2890 before prices rebounded at the close.

But until the last half-hour of trading, the Dow traded in a narrow, 18-point range and refused to drop below 2900 despite a steep drop in the dollar as well as a plunge in the stock of UAL Corp., which bludgeoned the transportation index.

The broad stock market took comfort from stability in the bond market -- where 30-year Treasury bonds were down only 1/32 as stocks closed -- as well as from a second session of impressive gains among issues of the Dow utility average.

UAL Corp. losses were accelerated by a published report that suggested that a second major backer, Citicorp, may be washing its hands of the proposed employee buyout of United Airlines. UAL plunged over 20 points at session lows, and closed down 17 7/8 at 139, bringing its two-session loss to nearly 15 percent.

At the close, the Dow stood at 2905.20, down 12.13, while advances edged declines on the New York Stock Exchange on moderately active but program-inflated volume of 173 million shares.

Bank stocks suffered some conspicuous losses today. Wells Fargo dropped 3 3/8 to 68 1/2, First Interstate lost 2 1/8 to 33 and Security Pacific surrendered 1 1/4 to 31 5/8 among California money-center banks, and Bankers Trust gave up 1 1/4 to 38.

But among other industry groups, oil shares and pharmaceuticals more than compensated.

Chevron rose 1 1/4 to 79 3/8 and Exxon gained 1 1/8 to 51 7/8 as New York September crude oil futures surged 48 cents to $20.69 per barrel on news that 100,000 Iraqi troops are deployed on the Kuwait border -- far more than had been previously estimated. The entire Kuwaiti army reportedly numbers only 20,000.

Atlantic Richfield rose 1 5/8 to 129 3/8, Pennzoil added 1 7/8 to 83 1/2, and Royal Dutch tacked on 1 3/8 to 83 3/8.

Pharmaceutical companies also provided stability to the broader market as Pfizer was pushed up 2 1/8 to 75 3/4, Bristol-Myers-Squibb gained 1 1/8 to 65, Warner-Lambert rose 1 1/8 to 68 1/4 and Biogen surged 3 1/8 to 26 3/4 in Nasdaq trading.

But the Dow transportation index, beyond the big UAL spill, served notice that rising energy prices are a double-edged sword. The transports toppled 31.58 to 1093.43 as UAL dragged it down.

But the Dow utilities enjoyed their second straight session of heavy gains, rising 2.95 to 210.01. Bullish traders said the utilities reflected market conviction of lower interest rates a few months ahead.

Among broad stock indexes, moves were marginal. The Standard & Poor's 500 finished up 0.60 at 356.16, the NYSE Composite was up 0.41 at 194.59, the Value Line fell 0.01 at 278.84, the Amex Market Value was off 0.05 at 353.60 and the Nasdaq Composite closed down 1.14 at 438.24.