Stocks rallied on Friday to close a second straight week of gains on hopes of collective action from global central banks if Sunday's election in Greece triggers market turmoil.
The news helped offset the latest round of weak U.S. economic data, which pointed to sluggish domestic growth. But traders were cautious and safe-haven U.S. bond prices also rose on Friday.
Materials <.GSPM>, energy <.GSPE> and financial <.GSPF> shares led the market's gains, with each of the three S&P 500 sector indexes up 1 percent or more.
Officials of the Group of 20 leading nations told Reuters on Thursday that central banks of major economies would take steps to stabilize markets and prevent a credit squeeze, if necessary.
The news spurred sharp gains late in Thursday's session. Later reports of the European Central Bank hinting at an interest-rate cut and Britain's pledge to flood banks with cash sparked further bullishness.
"It pokes a hole in the balloon of bad news after more bad news," said Richard Sichel, chief investment officer of Philadelphia Trust Co.
"None of the (U.S.) economic data we saw today were impressive. The gains seem to be based more on hope and less on the economic reports."
For the week, the Dow industrials gained 1.7 percent, the S&P 500 added 1.3 percent and the Nasdaq rose 0.5 percent.
Despite the stock market's gains, the safe-haven U.S. Treasury 10-year note shot up 18/32 in price, with the yield at 1.579 percent.
On Friday, the Dow Jones industrial average gained 115.26 points, or 0.91 percent, to 12,767.17 at the close. The Standard & Poor's 500 Index added 13.74 points, or 1.03 percent, to 1,342.84. The Nasdaq Composite rose 36.47 points, or 1.29 percent, to end at 2,872.80.
Spain's banking system remains an issue weighing on markets and the country's 10-year bond yield, at 6.92 percent, was still too close to the 7 percent mark at which other highly indebted euro-zone nations were forced to seek bailouts.
Some investors fear the Sunday elections in Greece may set the nation on the path to an exit from the euro zone. That possibility created volatility this week.
A gauge of manufacturing in New York state fell sharply in June, though it still showed growth, while an early June reading on consumer sentiment slipped to a six-month low on worries about the U.S. job market and Europe's debt crisis. The consumer sentiment reading was below consensus forecasts.
Recent economic indicators, including Thursday's unexpected rise in jobless claims, have pointed to sluggish growth in the U.S. economy. However, U.S. equities have largely tracked European developments in recent months, and shrugged off weak domestic data on occasion.
The lackluster U.S. data, alongside the possible turmoil following the Greek elections, could increase the chance that the Federal Reserve will signal more stimulus to counter slowing growth when it releases its policy statement next Wednesday at the close of a two-day meeting.
More than two issues rose for every one that fell on both the New York Stock Exchange and Nasdaq.
About 7.5 billion shares changed hands on the NYSE, the Nasdaq and Amex, compared with the daily average of 6.84 billion so far this year.