Updated

Stocks gained modestly on Friday, wrapping up a week of wild swings and enormous trading volumes on a bright note, as investors cautiously tiptoed back into the market to scoop up recently battered shares.

The blue-chip Dow Jones industrial average logged its best weekly gain since mid-May. But traders are still wary of nasty surprises after a roller-coaster week that saw stocks at 5-year lows on record trade volumes amid a cloud of worries over corporate profits and accounting scandals.

The Dow Jones Industrial average rose 78.08 points, or 0.95 percent, to 8,264.39, after weaving in and out of positive territory through much of the day. The Nasdaq Composite Index rose 22.04 points, or 1.78 percent, to 1,261.73. The index gained back nearly half of its losses Thursday. The broad Standard & Poor's 500 was up 14.16 points, or 1.69 percent, to 852.84.

For the week, Nasdaq fell 4.3 percent on the week and the S&P rose 0.6 percent. The Dow's 3 percent gain for the week was its best since mid-May. On Wednesday, the Dow and the Standard & Poor's 500 Index each posted percentage gains unseen since October 1987.

"I would argue the market is very, very undervalued," said Hugh Johnson, chief investment officer at First Albany Corp. "There is a strong case that could be made that the bear market is over, but there still has been no capitulation yet of the magnitude that we saw at other bear-market bottoms. That's the problem."

Investors tiptoed back into the technology sector after an almost 4 percent drop in the tech-laced Nasdaq on Thursday. Tyco International Ltd. (TYC) emerged as another pocket of strength in the market, leaping more than 45 percent after the troubled conglomerate named a former Motorola Inc. president as its new leader.

The late afternoon brought some selling which pushed stocks lower, as people were quick to take profits. Still, all major indexes finished the session higher.

"We are bottoming here and things are looking up," said Michael Kayes, chief investment officer of Eastover Capital Management. "There are encouraging signs the government is doing their job and more and more companies are doing what needs to be done. That's the process of rebuilding."

A report showing U.S. consumer sentiment was bruised in July but improved in the second half of the month helped lift investor sentiment a notch. The University of Michigan's final consumer sentiment index helped ease fears that consumer spending, a main driver of the the U.S. economy, would weaken.

Microsoft Corp. (MSFT) was up $2.52 to $45.35, or 5.88 percent, and helped boost both the Dow and the Nasdaq.

Tyco (TYC) surged $3.78 to $12.03 and ranked as the most active on the New York Stock Exchange. The troubled conglomerate named former Motorola President Edward Breen as its new leader. Breen replaces Dennis Kozlowski, who resigned last month, a day before he was charged with evading about $1 million in New York sales taxes on artwork purchases.

Motorola Inc. (MOT) fell $1.28 to $10.90 after Breen's departure. The wireless tech giant named as president and chief operating officer Mike Zafirovski, credited with turning around its mobile phone business, the world's second largest.

Qualcomm Inc. (QCOM) trimmed gains as doubts emerged about the wireless technology company's forecasts for sales of its mobile phone chips. Qualcomm soared 7 percent before the open after it posted earnings and sales that beat expectations. But it was last up 34 cents at $25.99, 1.3 percent.

Sprint Corp. (FON) plunged on rumors the telecommunications company faced a cash crunch and would not have enough money to pay off debt, analysts said. Sprint called the rumors of a cash crunch "misinformation," but the shares closed off 21.6 percent, or $1.95 at $7.05.

Chip gear maker Applied Materials (AMAT) added 9.1 cents to $14.321. Goldman Sachs upgraded the chip equipment sector to "market overweight" from "market weight," saying investment from funds and seasonality may drive a meaningful move in the stock. Among other sectoral firms covered by Goldman, Teradyne Inc. rose 26 cents at $14.33, and Novellus Systems Inc. rose 30 cents at $24.60 but others fell such as KLA-Tencor, off $1.16 at $37.29.

AOL Time Warner Inc. (AOL), the world's largest media company, rebounded $1.26 to $10.90. The stock plunged more than 15 percent on Thursday as Wall Street was focused on a U.S. Securities and Exchange Commission's inquiry into the accounting practices at the online unit.

Andrx Corp. (ADRX) lost $3.82 to $17.90. The maker and distributor of generic drugs reported a loss as legal and regulatory hurdles delayed the introduction of new copycat medicines and the company recorded a big charge to settle litigation.

Winning stocks outpaced losers about 5 to 3 on the New York Stock Exchange, and advancing stocks beat decliners 9 to 7 on the Nasdaq. About 1.8 billion shares changed hands on the Big Board and about 1.7 billion on the Nasdaq. Volume was heavy but less than the average volume of the past few days.

The Russell 2000 index, the barometer of smaller company stocks, rose 4.15, or 1.1 percent, to 382.26. The Russell ended the week down 1 percent.

Overseas, Japan's Nikkei stock average finished Friday down 3.4 percent. In Europe, Britain's FTSE 100 rose 1.3 percent, France's CAC-40 gained 0.7 percent, and Germany's DAX index advanced 1.7 percent.

Reuters and the Associated Press contributed to this report.