Stocks recorded their third big gain of the week and closed at a one-month high Friday because of expectations that the central banks of countries around the world will step in to limit the damage from a debt crisis in Europe.
The Dow Jones industrial average climbed 115 points.
Now investors wait for a crucial election on Sunday in Greece that will help determine whether that country stops using the euro as its currency. Such an exit would destabilize financial markets.
Mario Draghi, president of the European Central Bank, said his institution stood ready to support Europe's banking system by continuing to lend money to solvent banks. He also appeared to leave open the possibility of an interest rate cut.
Draghi said in Frankfurt that the ECB has a "crucial role" in extending credit to banks in times of instability, when banks can't always borrow money on financial markets.
Investors also are more confident about the election itself, said Peter Tuz, a money manager, at Chase Investment Counsel, which runs mutual funds.
"There's a growing sense of optimism," he said. "The betting now is that the 'let's stay in the euro' segment of the population will win."
Borrowing costs for Spain were unchanged. They fell slightly for Italy, an indication that investors are feeling a little better about that country's solvency. They have been worried that Italy will have to seek financial rescue.
The Dow rose 115.26 points to close at 12,767.17, its highest finish since May 11. The Standard & Poor's 500 index climbed 13.74 points to 1,342.84, also its highest since May 11. The Nasdaq composite index rose 36.47 points to 2,872.80.
For the week, the Dow rose 0.9 percent, the S&P 1 percent and the Nasdaq 1.3 percent.
The week included four moves of 100 points or more for the Dow, the first time that has happened since April:
— On Monday, the Dow lost 142 points as enthusiasm faded for a $125 billion rescue of Spanish banks.
— On Tuesday, the Dow climbed 162 after a Federal Reserve official said he supported more measures to stimulate the economy.
— On Thursday, the Dow gained 155, primarily because of late reports about possible coordinated action by central banks.
Energy stocks rose the most Friday. OPEC oil ministers agreed Thursday to keep their production target steady, a compromise meant in part to soothe economically troubled countries.
A pair of weak economic reports helped push Treasury prices up and yields down.
The yield on the 10-year Treasury note fell to 1.60 percent from 1.64 percent Thursday. Traders have been shifting money into the safety of the Treasury market ahead of the Greek election. That higher demand has kept yields near all-time lows.
Among stocks making big moves:
— Microsoft rose 68 cents, or 2.3 percent, to $30.02 following reports that the company is in talks to buy Yammer, a developer of social networks within companies.
— Capital One Financial rose 80 cents, or 1.5 percent, to $53.81 after the company said uncollectable and delinquent loans at its credit card business dropped last month.
— Defense contractor AAR plunged $1.23, or 10.6 percent, to $10.34. The company updated its forecast for fourth-quarter and fiscal-year earnings, and they were weaker than Wall Street expected.
— YPF, Argentina's state-controlled oil and gas producer, rose 72 cents, or 6.9 percent, to $11.17 after Mexican telecommunications billionaire Carlos Slim said he had acquired an 8.4 percent stake in the company.