Stocks Post Biggest Weekly Gains of 2012

Stocks closed higher in thin trading Friday, with all three major indexes log their best weekly gains this year, amid optimism that euro zone leaders would move closer to tackle the region's ongoing debt crisis, including a recapitalization of Spanish banks over the weekend.

“Bipolar markets here," said Alan Valdes, director of floor operations at DME Securities. "Yesterday, the market did not like what it heard from Bernanke. And today, we’re getting rumors out of Europe that Spain may get a bailout, which is lifting the market and the President spoke today begging for some action out of Congress."

“And don’t forget—next week is Quadruple Witching!” he added.

The Dow Jones Industrial Average rallied for a fourth-straight day led by Wal-Mart , which hit a 12-year high earlier in the session.

The S&P 500 and the Nasdaq also ended higher. The CBOE Volatility Index, widely considered the best gauge of fear in the market, dropped near 21.

For the week, the Dow surged 3.59 percent, the S&P 500 jumped 3.72 percent, and the Nasdaq soared 4.04 percent. All 30 Dow components logged gains for the week, led by Home Depot and BofA .

All 10 S&P sectors also finished in the black this week, led by financials and materials.

Facebook rallied to close above $27 a share, but still finished lower for the week. Meanwhile, UBS said its losses on Facebook trading may be as high as $350 millionand the firm is preparing legal action against Nasdaq as a result, sources told CNBC.

Spain will "formulate a request for aid exclusively for banks recapitalization," according to ECB Vice President Vitor Constancio in remarks aired by Portugal's Radio Renascenca, adding that "everything is possible," when asked whether the request may happen Saturday.

The news comes after Fitch downgraded Spain's sovereign ratingby three notches to 'BBB' on Thursday, citing urgent need for bank recapitalization. And an IMF report showed Spain's troubled banks need a cash injection of at least 40 billion euros($50 billion).

European shares fellfollowing a disappointing trade report from Germany and amid jitters over Spanish banks.

“The market is showing irrational fear about current events in Europe and China,” said Doug Cote, chief market strategist for ING Investment Management. “Investors have been pricing in a worst-case scenario and once they realize we’re not there, the biggest risk in this market right now is for investors not to participate in the melt-up that we think is highly likely.”

President Obama put pressure on European leadersto act quickly to solve the region's ongoing sovereign debt crisis, suggesting solutions such as injecting capital into weak banks. Obama warned that Greece's hardships will continue to grow if the debt-ridden nation exists the euro zone.

Obama also said he will pressed Congress to pass economic measures he has proposed to spur job growth in the U.S.

Stocks staged its best one-day rally this year on Wednesday amid hopes that central banks around the world will implement further measures to support the global economy. But investors were disappointed after Bernanke made no specific commitmentto more easing. The Fed is scheduled to hold its next policy meeting on June 19 to 20.

McDonald's slumped after the fast-food leader and Dow component said global same-store sales rose a disappointing 3.3 percent in May, hit primarily by weakness outside the U.S. Rival Yum Brands also declined.

FedEx Freight announced it will increase shipping rates by 6.9 percent effective July 9th.

Chesapeake announced it will sell its pipeline and related assets in a deal worth $4 billion, which will help cover a $9 billion to $10 billion funding shortfall in the next three years.

An Apple lawyer said the iPhone maker may seek a legal order stopping the launch of Samsung's Galaxy S III phone in the U.S. later this month. Meanwhile, Nokia rallied following market rumor that the cellphone maker might be a takeover target of Samsung.

Navistar surged after billionaire investor Carl Icahn boosted his stake in the truck and engine maker to 11.87 percent from 9.99 percent.

Kraft Foods announced it will switch its exchange listing to the Nasdaq from the New York Stock Exchange, which will help the company save money. The food and beverage conglomerate will maintain its current ticker symbol "KFT."

On the economic front, the U.S. trade deficit narrowed in Aprilto $50.1 billion, according to the Commerce Department. Both imports and exports were still the second highest on record. And wholesale inventories climbed 0.6 percent to a record $483.5 in April, according to the Commerce Department, after an unrevised 0.3 percent gain in March.

—By CNBC’s JeeYeon Park (Follow JeeYeon on Twitter: @JeeYeonParkCNBC)

On Tap Next Week:

MONDAY: Apple WWDC event, Atlanta Fed Pres Lockhart speaks, San Francisco Fed Pres Williams Speaks, Cleveland Fed Pres Pianalto Speaks
TUESDAY: NFIB small biz optimism index, import & export prices, Fed Gov. Tarullo speaks, 3-yr note auction, GM shareholders mtg
WEDNESDAY: Weekly mortgage apps, PPI, retail sales, business inventories, oil inventories, 10-yr note auction, OPEC mtg, Caterpillar shareholders mtg, Dimon testifies before Senate
THURSDAY: CPI, jobless claims, current account, 30-yr bond auction, AOL shareholders mtg; Earnings from Kroger, Smithfield Foods, Pier 1 Imports
FRIDAY: Empire state mfg survey, treasury int'l capital, industrial production, consumer sentiment, credit card default rates reported, quadruple witching

More From CNBC.com: