Stocks erased early losses and rose Friday, wrapping up a second week of gains, on momentum from the market's recent surge from 5-year lows and surprisingly strong earnings from software giant Microsoft Corp.

The blue-chip Dow Jones Industrial average rose 47.36 points, or 0.57 percent, to 8,322.40 while the tech-loaded Nasdaq Composite Index gained 15.57 points, or 1.22 percent, to 1,287.86, boosted by Microsoft. The broad Standard & Poor's 500 Index added 5.19 points, or 0.59 percent, to 884.39. All three fell in the morning, with the Dow down more than 100 points.

For the week, the Dow rose 6 percent, Nasdaq 6.4 percent and the S&P 500 5.9 percent. The market had closed higher last week as well, snapping a six-week losing streak.

"The market was down this morning for no good reason in particular but the comeback proves that people are willing to buy on dips," said Peter Boockvar, equity strategist at Miller Tabak. "The economy is still weak and there are fears over global geopolitics, but the market is taking this leap of faith that things are not as bad as perceptions."

Microsoft Corp. (MSFT) rose more than 4 percent after posting earnings that more than doubled and hiking its outlook. But other technology shares, including Web security company Check Point Software Technologies Inc. (CHKP), software maker Siebel Systems Inc. (SEBL) and chip maker Broadcom Corp. (BRCM), sank on weak forecasts or analysts' calls.

Mixed economic data showed tame consumer-level inflation in September and a record U.S. trade deficit in August, but the market showed little interest in the numbers. U.S. consumer prices edged up 0.2 percent, as the cost of energy and cars jumped, but inflation elsewhere in the economy was muted. The trade deficit widened in August to a record $38.46 billion.

Investors have sent the market to higher closes six out of the past seven sessions as better-than-expected earnings out of bellwethers like computer maker International Business Machines Corp. and financial heavyweight Citigroup Inc. sparked hopes that an end to the long bear market is in sight.

Friday is the closest trading day to the 15th anniversary of the stock market crash of October 19, 1987, when the Dow sank more than 22 percent. This was one of several crashes, also including the 1929 market massacre, that give October the "jinx month" tag.

But according to the Stock Trader's Almanac, October is also known as a "bear killer" when the tide turned in several bear markets.

"There is an urgency to participate among professional managers," said A.C. Moore, chief investment strategist at Dunvegan Associates. "Any time markets start to have more of a luster to them, you will see that investment managers participate rather than not, or else ultimately they are out of a job."

Dow component Microsoft rose $2.38 to $53.15. The company topped estimates as sales surged on a new software licensing plan and raised its full-year revenue and earnings outlook.

EBAY Inc. (EBAY) gained $1.81 at $59.96. The online auction site posted earnings that surpassed forecasts, but some analysts said they were disappointed with the company's new guidance for the fourth quarter and for 2003.

Software maker Siebel (SEBL) slumped $1.09, or more than 15 percent, to $6.20. The company posted a third-quarter net loss, its first in four years, and issued a current-quarter forecast below Wall Street's consensus expectation.

Communications chip maker Broadcom (BRCM) lost $1.82 to $10.63. The company reported a narrower quarterly loss as revenues rose almost 36 percent, but it cautioned current revenues will be flat from the third-quarter and below estimates. Goldman Sachs cut Broadcom to "market outperform" from "recommend list".

"There's a mixed reaction to the earnings. A lot of traders are trying to trade the Microsoft news ... I think the rally will continue," said Kathy Carey, trader, at Wedbush Morgan. "But Siebel was not that positive and Goldman dropped Broadcom and the semiconductor stocks are weak."

Internet security company Check Point (CHKP) sank $3.45 to $13.28 after posting lower profits and saying it sees fourth-quarter results flat to slightly down from the third quarter.

Shares of Sprint Corp. (FON) rallied after the No. 3 U.S. long-distance telephone company posted a third-quarter profit as cost-cutting efforts helped offset weak demand for long-distance, wireless and data services. Sprint FON Group , the telephone and data business, scrambled up $1.22 to $11.89. Sprint PCS (PCS), the wireless telephone unit whose stock trades separately, rose 44 cents to $2.82, 18.4 percent.

Biogen Inc. (BGEN) said earnings fell as sharper competition cut into sales of Avonex, a multiple sclerosis drug, but shares rose nearly 9 percent following news that Biogen had settled a dispute with drugmaker Schering-Plough Corp. (SGP). Schering-Plough will resume royalty payments on hepatitis drugs for which Biogen holds the patents. Biogen jumped $3.44 to $36.81 and Schering lost 46 cents to $18.94.

Oil services giant Schlumberger Ltd. (SLB) climbed $2.99 to $40.69. It said Chairman and Chief Executive Euan Baird will retire from the company on Feb. 1, 2003 and will be succeeded by President and Chief Operating Officer Andrew Gould. Morgan Stanley upgraded Schlumberger to "overweight" from "underweight" saying Gould's appointment to the top spot gives it much increased confidence in the firm's strategic outlook.

Decliners outnumbered advancers narrowly on the New York Stock Exchange but gainers narrowly topped losers on Nasdaq. More than 1.42 billion shares changed hands on the Big Board and more than 1.66 billion on Nasdaq in active trading.

The Russell 2000 index, the barometer of company stocks, inched up 0.28, or 0.1 percent, to 362.85.

Overseas, Japan's Nikkei stock average finished Friday up 1.4 percent. In Europe, Germany's DAX index declined 0.3, France's CAC-40 lost 0.9 percent, while Britain's FTSE 100 fell 1 percent.

Reuters and the Associated Press contributed to this report.