Cautious optimism about corporate earnings helped stock indexes stage a late rally Friday, but Wall Street remained on edge amid more reports of bioterrorism while the United States rained bombs on Afghanistan.

The Dow Jones industrial average climbed 40.89 points, or 0.46 percent, to end at 9,204.11, after spending the bulk of the session in negative territory. The Nasdaq composite rose 18.58 points, or 1.12 percent, to 1,671.30. The benchmark Standard & Poor's 500 index was up 4.87 points, or 0.46 percent, at 1,073.48.

For the week, the Nasdaq fell 1.9 percent, the Dow slipped 1.5 percent and S&P 500 dropped 1.7 percent. Since the Sept. 11 attacks, Nasdaq is down 1.4 percent, Dow down 4.2 percent and S&P off 1.7 percent.

Investors were also jittery on the 14th anniversary of the Oct. 19, 1987, stock market crash, when the Dow average plunged a stunning 22.6 percent.

"Earnings are looking good, companies are doing better, for the most part than many people thought,'' said William Rutherford, president and chief executive of Rutherford Investment Management. "But the Middle East uncertainties on terrorism are weighing heavily on the market at the moment.'' 

Asked what was weighing on the market, Rutherford said: ''Anthrax, in a word.''

Anthrax cases have popped up around the nation and reports emerged Friday that an employee of The New York Post, one of New York City's daily tabloid newspapers, tested positive for the potentially deadly bacteria. Anthrax cases have spread over the globe, with confirmed cases of anthrax surfacing in Kenya and with buildings in Britain, Peru, Fiji and the Netherlands evacuated on Friday as suspicious mail was rushed for tests.

Investors are hoping for a turnaround in the economy and corporate profits by 2002, but are getting hit with weak earnings from many quarters.

The blue-chip Dow average got a boost from Coca-Cola Co., which rose $2.47 to $48.59 after UBS Warburg added the soft-drink giant and chocolate maker Hershey Foods Corp. to its "highlighted stocks" list. Hershey, which gained $2.49 to $64.55, reported higher earnings early Friday.

Microsoft fell before ending up $1.15 at $57.90, helping both the Dow and Nasdaq. The company said it had not seen a huge impact from the Sept. 11 attacks on New York and the Pentagon, but added the economic outlook was hard to forecast.

On a more upbeat note, PeopleSoft gained $2.26 to $26.56, or 9.3 percent, after its earnings beat lowered forecasts. KLA-Tencor added $1.63 to $36.51, or 4.7 percent, after it reported increased profits and revenues and cited strong orders from the United States and Taiwan.

Emulex Corp. soared $4.60 to $24.65, nearly 23 percent. The storage equipment maker posted a sharp loss for its fiscal first quarter, but operating earnings of $7.5 million still edged ahead of forecasts. Among sectoral issues, Brocade Communications rose $2.28 to $24.69.

"If your time horizon is 12 to 18 months, I am not sure how important it is. But if your time horizon is three weeks or a month or two, beating expectations that had been dramatically lowered might allow a stock to go up," said Rosenthal. "I think we are seeing some of that."

Finland's Nokia rose $1.32 to $20.10 in active trading. The world's largest mobile phone maker indicated it was weathering the current slowdown well, bolstered by its new range of phones.

eBay Inc. tumbled $7.11 to $51.95. The Web auction site delivered more strong sales and earnings, but cautioned that its holiday business may suffer as consumer buying slows.

Credit card issuer Providian Financial Corp. plunged 58.47 percent, or $7.25 to $5.15, and was the most active on the New York Stock Exchange. The company posted a 71 percent drop in profits amid customer defaults and said it will look for a new chief executive.

The latest economic news showed the Consumer Price Index -- a key gauge of national inflation -- rose at a stronger-than-expected 0.4 percent rate in September following a 0.1 percent August gain. Inflation, though, is not the market's focus at the moment, analysts said, adding Wall Street realizes Federal Reserve Chairman Alan Greenspan has to be more concerned with turning the economy around rather than worrying about slight signs that there could be some inflationary pressure building.

Advancing issues outnumbered decliners slightly more than 4 to 3 on the New York Stock Exchange. Volume was 1.26 billion shares, the same number of shares traded Thursday. 

The Russell 2000 index, the gauge of smaller company stocks, inched rose 4.64 to 425.70. 

Overseas markets were mostly lower Friday. Japan's Nikkei stock average ended the day with a gain of 0.6 percent, but European stocks suffered. Britain's FT-SE 100 fell 1.9 percent, France's CAC-40 lost 1.7 percent and Germany's DAX index declined 1.3 percent.

Reuters and the Associated Press contributed to this report.