A frantic wave of last-minute trading on Wall Street tied to expiring options and futures drove the stock market sharply higher yesterday.

About 40 million shares worth about $1.7 billion changed hands at the closing bell as market participants closed out their positions in controversial, computer-directed "program trading" strategies.

The closely watched Dow Jones industrial average, which was up about 13 points just prior to the 4 p.m. close, rocketed suddenly to a 23.68-point gain as huge multimillion-dollar buy or sell programs hit the floor. Depending on their direction, the programs have the capacity to send the market soaring or plunging.

The Dow closed at 1,879.54 on New York Stock Exchange volume of 149.1 million shares, but broader market indicators turned down as declining stocks led advancers by 888 to 762.

Yesterday was expiration day for options on stocks, options on stock indexes and futures contracts on stock indexes, often called the "triple witching hour." These triple expirations occur four times a year.

Traders agreed that the market swing might have been much greater, but noted that many traders already had sold off their programs or moved them over to the next expiration period in September.

R. Sheldon Johnson, head of equity index products at Morgan Stanley & Co., said he saw three or four sell programs and six to eight buy programs move through the trading floor during the day, but said he could not tell how many programs were entered at the close.

He previously had predicted that index funds were ready to buy as much as $800 million at the close. That dwindled to about $200 million by late yesterday, Johnson said.

To be successful in their computerized strategies, program traders must sell or buy their stocks exactly at the closing price on expiration day.

Volume on the NYSE stood at about 110 million shares just before 4 p.m. By the time the huge blocks of stock had finished trading, volume grew by almost 40 million shares.

Program trades often involve hundreds of different shares of stock and millions of dollars. Used by cash-rich investors such as brokerage houses and pension funds, program traders profit by keying on the disparities between the prices of stocks and the prices of stock index futures.

Traders spent most of day watching stocks fluctuate narrowly on light volume. At 3:30 p.m., the Dow industrials were only 2.21 points ahead.

So dull was the action on a day so widely anticipated that Larry Wachtel, Prudential-Bache's chief trader, said:

"They don't make witches the way they used to."

The day was a near-replica of the triple close last June when the Dow finished up 24.75 points on a volume of 125.4 milllion. In March, the last expiration day, the Dow fell 35.68 points.

Many factors can affect what happens on expiration days. Because program trading is tied to the prices of stocks and the prices of futures contracts, the trades are triggered by price swings in the two markets. Stocks are bought and futures contracts are sold when the price gap widens.

Similarly, the programs often are terminated in advance of expiration days when the price gap narrows. Or, if the prices are in balance, the programs are advanced to the next expiration day, in this case, September. Traders agreed yesterday that many programs were sold early or moved ahead because of economic incentives.

Triple witching hours have come under scrutiny from the Securities and Exchange Commission and the Commodity Futures Trading Commission. The regulators have asked the exchanges to consider several proposals to reduce the volatility caused by expiration-day trading.

In action on individual stocks, the Associated Press reported:

Dart & Kraft led the active list, up 4 at 64 3/8 on a turnover of more than 3.7 million shares. The company plans to split into two separate entities, in a move it said is intended to increase shareholder value.

U.S. Tobacco jumped 4 3/4 to 40 3/4. A jury ruled in favor of the company in a product liability suit concerning smokeless tobacco.

Other tobacco stocks also rose on the verdict.