NEW YORK (AP) _ At 2:40 p.m. on Friday, Oct. 13, the New York Stock Exchange halted trading in shares of UAL Corp. on reports that a $6.75 billion buyout was collapsing.

Instantly the news poisoned the market for stocks of other takeover targets. If financing fizzled for the labor-management takeover of United Airlines' parent, what deal was safe?

By 3 p.m. the Dow Jones industrial average had tumbled 56.97 points. Panic spread through the hundreds of traders, specialists and clerks on the floor of the three-story trading atrium.

''Every arb and his brother sold everything he could get his hands on,'' said a major Wall Street arbitrager who dumped a large UAL stake at a loss.

By day's end, the Dow average declined 190.58 points, the second-largest point drop in history. And all thoughts turned to Monday, Oct. 19, 1987, when the market crashed after a similar Friday selloff.

In the 65 hours from Friday's close to the market's opening Monday, unprecedented steps were taken to keep credit lines open, promote post-crash safety measures and allay investors' fears.

Interviews with exchange leaders, government officials and market professionals show that those steps - all taken with 1987 in mind - helped stop the Friday the 13th selloff from becoming Nightmare on Wall Street Part II.

''It was knowing that the possible consequence of inaction could be so dire that we all had to act that way,'' said Ivers Riley, senior vice president at the American Stock Exchange.

The bounce-back also suggested that leadership, more than regulation, proved the key to holding the markets together. What prevented a second coronary, officials said, was not ''circuit-breaker'' trading halts, but a determination to maintain calm so that orderly buying and selling - even high- volume computerized trading - could proceed.

''The more progress we can make towards bringing the regulation into one place, or to bring it into a high degree of coordination, the better off we're going to be at it,'' Treasury Secretary Nicholas Brady said.

Extraordinary action was evident everywhere, from Treasury Department backrooms in Washington, to trading rooms at New York brokerages, to suburban living rooms where executives mapped strategies while the World Series played on TV.

-After checking his bank credit line, a veteran NYSE specialist arranged $20 million in emergency financing from friends - just in case of another Black Monday. The specialist had to buy a remarkable $25 million of stock in 75 minutes Friday, doubling his normal daily inventory, to fulfill his role as a ''market maker'' who ensures smooth trading.

-Treasury Department, Federal Reserve and Securities and Exchange Commission officials analyzed Friday's trading and telephoned important market participants. ''We were at it all weekend,'' one source said.

-About 200 Amex traders and officials gathered Saturday to complete the paperwork on Friday's hectic dealings. NYSE leaders called member firms and specialists to ensure they had adequate capital should the market collapse. Technicians checked computers that NYSE officials had hailed for months as fully capable of handling enormous volumes.

-Retail brokerages opened offices in a broad campaign to ease fears. Executives at Prudential-Bache Securities Inc. - whose 6,500 brokers at 325 branch offices fielded client calls all weekend - dictated the company line via the firm's nationwide communications network: ''This is not 1987.''

Despite those assurances, the spooky similarities between Friday the 13th and Friday, Oct. 16, 1987, dominated everyone's thinking. Fears about rising interest rates and the decline of the 1980s takeover boom played roles in both Friday slides.

The market already was down about 25 points when the UAL announcement hit. Arbitragers - stock speculators who seek to profit on short-term rises in takeover targets like UAL - exited quickly.

Money managers for pension funds, insurance companies and mutual funds followed. Some reported phone lines were so clogged they couldn't get orders in - another Black Monday reminder.

''You had a bandwagon psychology,'' one NYSE floor specialist said. ''They became fearful for a repeat of the crash and you had a headlong retreat.''

Cramer & Co., a New York firm that manages $20 million in assets, reduced the stock segment of its portfolio from 35 percent to 10 percent, joining a wave triggered by frantic selling of stock-index futures.

Many professional trading strategies exploit the links between the stock market and contracts traded in the futures markets that are based on the future prices of large groups of stocks.

''Once the UAL deal broke there were massive sell programs in futures,'' said Cramer president, James J. Cramer.

Hot lines among the major exchanges in New York and Chicago, installed after the 1987 crash, were opened Friday when the market began tumbling. Phone links also were established with Washington.

After the close, even the biggest firms checked with banks to ensure they had adequate capital and credit lines that could be expanded if necessary. Traders stayed late into the night dissecting what happened.

Some Wall Street executives conferred in emergency sessions on Saturday and Sunday, but panic wasn't apparent; the president of one major brokerage attended ''family weekend'' at his daughter's upstate New York college.

The firms - whose long-term profitability depends on demand for stocks - worked to control the damage. At 5:30 p.m. Friday, for example, Merrill Lynch & Co. issued a statement aimed at soothing investors, noting what it called the differences between 1989 and 1987.

Merrill and its competitors emphasized the economy was slowing and the dollar was strong, vs. October 1987 when the economy was growing sharply and the dollar weak. Shearson Lehman Hutton Inc. analysts compiled a list of stocks to recommend.

''What we had to do was kind of say, 'You should not overreact and liquidate positions. The right thing to do is stay in there,''' said Richard Sichenzio, retail group president at Prudential-Bache.

Still, Wall Street feared two major possibilities: Investors would ignore the advice and overseas markets would react negatively to Friday's selloff.

In an attempt to forestall those prospects, a Federal Reserve official said Saturday the Fed would inject as much money as necessary into the banking system to avoid a crisis. It was an extraordinary pronouncement by the Fed, which almost never discloses its intentions. In 1987, the Fed didn't act until after the crash.

NYSEofficials, meanwhile, touted post-crash innovations designed to stem a market landslide, including the ''circuit breakers'' that would halt trading temporarily in New York and Chicago if prices sunk below certain levels.

On Sunday night, Wall Street strategists gathered to monitor the market opening in Tokyo, where it was Monday morning. The Japanese market fell less than 2 percent and stabilized.

At Morgan Stanley & Co., one of the biggest Wall Street brokerages, equities divisions held a 6 a.m. strategy session with linkups to London and Tokyo.

''I don't feel at all that this is a situation that's comparable to 1987 and that we're looking at a big crash,'' Morgan's chief strategist, Barton Biggs, told employees in an 8:15 a.m. video and telephone hookup.

The New York market opened lower, partly because stock-index futures prices in Chicago tumbled and stock prices followed. But a lack of selling by large institutions such as pension funds and insurance companies sent a positive signal.

When a major futures index suddenly turned upward, so did the underlying blue-chip stocks, where bargains abounded, like IBM at less than $100 a share. The Dow Jones rallied, finishing up 88 points on the day, and the crisis faded.

The absence of ''portfolio insurance,'' a strategy blamed for accelerating the 1987 decline in stock and stock-index futures prices, may have helped arrest another panic, some professionals said. But some forms of program trading were still very much in evidence.

In the end, it may have been the fear of disaster that prevented one.

''People certainly have a memory,'' said Joseph Schmuckler, a senior vice president at Kidder Peabody & Co. ''They were a lot more concerned. I think being very conscious of what happened two years ago was very positive.''

End adv Sunday, Oct. 22, and thereafter