The Dow Jones industrial average rose 59.17 points, or 0.47 percent, to end at 12,612.13. The Standard & Poor's 500 Index gained 5.05 points, or 0.35 percent, to 1,452.85. The Nasdaq Composite Index advanced 11.62 points, or 0.47 percent, to close at 2,491.94.
The S&P 500 has now recovered all of its losses since Feb. 27 when a tumble in the Chinese stock market sent equities reeling worldwide. The Dow and the Nasdaq have yet to fully recover their losses from that sell-off.
A possible buyout of student-loan company Sallie Mae also helped lift shares, along with higher first-quarter profits from General Electric Co. (GE), which brightened the outlook for the earnings season that began this week.
The earnings and M&A news overshadowed a report showing a drop in a closely watched consumer sentiment index to an eight-month low.
"It's been a very resilient market, and I think this shows you how strong it will continue to be. There's a tremendous amount of liquidity out there," said Stephen Massocca, co-chief executive of San Francisco-based investment bank Pacific Growth Equities.
"You could have some bad earnings numbers, but I think earnings are going to be better than expectations," he said.
Friday's advance brought the Dow back to just 20 points below its Feb. 26 close and the Nasdaq to about 12 points from its finish on the day before the huge global equities sell-off.
For the week, the Dow gained 0.41 percent, the S&P 500 rose 0.63 percent and the Nasdaq climbed 0.83 percent.
Merck led the Dow industrials' gains, climbing 8.3 percent to $50.21 after it raised its profit forecast for both the first quarter and the full year. Earlier, Merck rose to $50.80, the highest level since October 2003, and boosted shares of other drug makers. An index of pharmaceutical shares gained 2.3 percent.
McDonald's, another Dow component, hit a seven-year high at $47.92 after the world's largest restaurant company said its first-quarter earnings would beat analysts' expectations.
McDonald's gained up 2.2 percent to close at $47.64 on the New York Stock Exchange.
General Electric, often considered a bellwether for the economy, was up 0.6 percent at $35.38 after posting a higher quarterly profit and reaffirming its outlook. GE's businesses range from making jet engines to running media and entertainment company NBC Universal.
Shares of Apple Inc. fell, helping to limit the Nasdaq's gain. The company said it was delaying the release of its new computer operating system. Also, UBS cut its 2007 earnings outlook on the company. Apple slid 2.1 percent to $90.24.
Shares of Sallie Mae jumped 14.8 percent to $46.76 after the New York Times reported that the largest U.S. student-loan company was in talks to sell itself to private equity firms.
The market's advance was limited early in the day by the University of Michigan/Reuters consumer sentiment survey. Its preliminary reading for April showed that consumer sentiment fell to its lowest level in eight months while consumers' expectations for inflation shot higher.
Before the opening, a report showed core producer prices were unchanged last month.
The Producer Price Index, excluding food and energy costs, was unchanged in March. Initially, the tame core PPI reading had soothed inflation worries stoked earlier this week by minutes from the Federal Reserve's most recent meeting. The Fed minutes, released on Wednesday, had hinted at the need for more interest-rate increases.
The overall PPI for March, however, rose more than economists had forecast.
Volume was moderate on the NYSE, where about 1.42 billion shares changed hands, below last year's daily average of 1.84 billion. Om the Nasdaq, about 1.89 billion shares traded, slightly below last year's daily average of 2.02 billion.
Advancers beat decliners by a ratio of about 5 to 3 on the NYSE and by about 2 to 1 on the Nasdaq.