US stocks went from famine to feast this week with a mid-week swoon giving way to a big rally following Friday's April jobs report.
The Dow Jones Industrial Average finished the week up 167.05 points (0.93 percent) at 18,191.11, while the broad-based S&P 500 advanced 7.81 (0.37 percent) to 2,116.10, less than two points below a record.
The tech-rich Nasdaq Composite Index slipped 1.84 (0.04 percent) to 5,003.55.
Factors behind the weakness in the first part of the week included lackluster economic data. The US trade deficit in March jumped more than 40 percent to a six-year high, due in part to the strong dollar.
Analysts also cited worries about higher oil prices as well as the continued logjam in talks between Greece and its creditors on a package to unlock bailout funds.
Stocks also sold off after US Federal Reserve Chair Janet Yellen characterized US stock market valuations as "quite high" and said they pose "potential dangers" to financial stability.
Analysts said Yellen's comments suggested the Fed is eager to raise ultra-low interest rates despite some disappointing economic data.
"She seems to be hinting that they're going to have to raise rates one way or the other as long as the economy is growing at all," said Chris Low, chief economist at FTN Financial.
But US stocks rallied Thursday and again Friday after the Labor Department reported the US economy added a solid 223,000 jobs in April and unemployment fell to a seven-year low of 5.4 percent.
David Levy, portfolio manager at Kenjol Capital Management, said the jobs figure came in at a "sweet spot" for Wall Street because it suggested the economy had turned a corner after a weak first quarter.
At the same time, the US labor market showed some signs of weakness, with wages barely growing and underemployment still elevated. That suggested the Fed would not hasten its plan to raise interest rates, Levy said.
"Investors are breathing a sigh of relief," Levy said Friday afternoon.
- McDonald's turnaround outlined -
In corporate news, fast-food chain McDonald's unveiled a long-awaited turnaround plan under new chief executive Steve Easterbrook, who reorganized the company's international operations and announced plans to sell off more company-owned restaurants to franchisees.
But McDonald's shares fell after the plan was released. A note from Morningstar called the plan "somewhat lacking" on menu details.
In merger news, Alexion Pharmaceuticals announced another big deal in the drug business, saying it would buy Synageva BioPharma for $8.4 billion to create a bigger player in treatments for rare diseases.
Alibaba rallied after reporting a 45 percent gain in revenues to $2.1 billion in the January-March quarter, though profits plunged by nearly half. The Chinese e-commerce giant named chief operating officer Daniel Zhang as chief executive, replacing Jonathan Lu.
Online listings and review site Yelp surged on reports it is considering selling itself, while shares of cloud computing company Salesforce lurched up and down on shifting reports on its possible acquisition by Microsoft or another large tech player.
Cisco Systems announced longstanding chief executive John Chambers would step down and be replaced by another company veteran, Chuck Robbins.
Cisco reports quarterly earnings next week. Dow member DuPont will also be in the news with an annual meeting that will consider activist fund Trian Fund Management's efforts to win four board seats.
There are also a handful of economic reports, including US retail sales for April.