Stocks ended higher at the end of a quiet week of trading, as investors were encouraged by further moves by the Federal Reserve and a vote of confidence for the nation's largest mortgage lender.
The Dow Jones Industrial Average posted a weekly gain of 1.9%, the S&P 500 rose 1.9% and the Nasdaq Composite advanced 2.4%.
For the year, the blue chip Dow index remains up 6.9% in 2007, the benchmark S&P 500 is up 3.8% and the Nasdaq has gained 6.1%.
U.S. stocks ended Monday mixed but closed above session lows as investors remained troubled by problems in the mortgage market and their long-term effects on the broader economy.
"We're probably through the brunt of the volatility stage," said Keith Wirtz, chief investment officer at Fifth Third Asset Management. "There hasn't been much liquidity in terms of participants in the marketplace but once we get to September we think the Fed is going to go through an adjustment of interest rates and that's going to give the relief to the market."
Home improvement retailer Lowe's posted a gain in second-quarter profit, as new stores boosted total sales.
Stocks ended mixed on Tuesday as investors looked for signs that the Federal Reserve may cut interest rates again soon.
Federal Reserve Chairman Ben Bernanke and Treasury Secretary Henry Paulson met with Senate Banking Committee Chairman Christopher Dodd on Tuesday morning to discuss the recent market volatility.
Sen. Dodd, a Democratic presidential candidate, told reporters after the meeting that the Fed is working diligently on credit regulatory reform and the central bank was prepared to "use all tools available to them."
"I think it's encouraging that we are kind of stabilizing after last week's turmoil," said Alec Young, equity market strategist at Standard & Poor's. "In the short term, people are trading on the Fed cues. The meeting was positive in that Bernanke seemed willing to use all tools available."
Target reported earnings that met Wall Street expectations . Shares of the second-biggest U.S. discount retailer rose more 5%.
BJ's Wholesale Club said second-quarter profit spiked 37%, topping expectations, as sales rose 8% from the year-ago period. The stock closed with a gain of 8%.
A late rally pushed stocks sharply higher on Wednesday as takeover news and speculation of a Fed interest rate cut overshadowed credit jitters.
"We think that liquidity is returning to the market after being problematic," said Kevin Cronin, head of investments at Putnam. "We think the Fed's actions last week righted the ship, and we think things are going to get better going forward."
Citigroup said its banking unit, Citibank, borrowed $500 million from the Fed discount window to fund clients. The other three largest U.S. banks also took the unusual step of borrowing directly from the Fed with Bank of America, JPMorgan Chase and Wachovia each borrowing $500 million.
Lehman Brothers announced it was closing its BNC Mortgage unit, a move that will affect the division's 1,200 employees.
Mining company Rio Tinto said it has funds necessary for its $38.1 billion takeover of Canadian aluminum producer Alcan , despite recent market turbulence.
Shares of MGM Mirage rose sharply on news Dubai World, the investment holding firm of the Dubai government, will acquire a 9.5% stake in the casino operator and a 50% interest in MGM's CityCenter development project for $5 billion.
U.S. stocks rebounded from intraday lows but closed Thursday with small losses amid ongoing worries regarding the global credit environment.
"The conventional logic was that the worst was behind us but then reality set in and there's still trouble out there," said Dan McMahon, head of listed trading at CIBC World Markets. "It's just the tip of the iceberg as to how far this thing will trickle down and whether or not this is a real phenomenon or just fear."
Mortgage lenders traded higher after Bank of Americaannounced it would pour $2 billion into troubled lender Countrywide Financial .
Countrywide shares surged at the open but pared gains after CEO Angelo Mozilo told CNBC's Maria Bartiromo in an exclusive interview that the credit market environment is not improving and believes the housing slump will lead the economy into a recession.
Home Depot was the biggest percentage decliner among Dow components, falling 2.2% on news that the sale of its supply unit was in jeopardy.
Stocks ended the week on a sharply positive note Friday following the release of solid economic data.
"We saw an extreme representation of buying opportunities, and this is the snap-back rally," said Marc Pado, U.S. market strategist at Cantor Fitzgerald. "We're powering up, we'll sit at a high point here and we'll probably see some sort of a test (to the downside) next week."
Peter Kang is a markets writer at CNBC.com and can be reached at firstname.lastname@example.org.