US Markets

Dow ekes out weekly gain as overseas worries fade

CNBC update: Yellen expects a rate hike this year
CNBC update: Yellen expects a rate hike this year
Cashin: Hope for Greece lifts stocks
Cashin: Hope for Greece lifts stocks
Why China stock market bailout might work: NYT's Stewart
Why China stock market bailout might work: NYT's Stewart
Pisani's market open: Catching traders off sides
Pisani's market open: Catching traders off sides

U.S. stocks closed more than 1 percent higher on Friday, recovering from a sharp selloff earlier in the week, as hopes for resolution in Greece and stabilization in China boosted sentiment. (Tweet This)

The Dow Jones industrial average closed about 210 points higher after gaining nearly 250 points in afternoon trade. The blue chip index eked out a 0.17 percent gain for the week but remains about a third of a percent lower for the year so far.

The S&P 500 recovered gains for the year but failed to hold higher for the week, ending flat for the five-day session.

The Dow transports gained nearly 1 percent for the week, closing up nearly 1.9 percent on Friday as airlines surged. The index posted its first weekly gain in five.

The Nasdaq Composite gained 1.5 percent as biotechs rallied and Apple closed up 2.67 percent, reversing a 2 percent plunge Thursday that took the stock close to its 200-day moving average.

Read More PC shipments plunge, but Apple surges

"This has been a week where everyone worried about China and Greece and as we go into the weekend those big financial headwinds are less scary," said David Kelly, chief global strategist at JPMorgan Funds. "There's clearly more optimism that a a Greece deal (is reached)."

Performance this week

Greece's banks will need an estimated 10 to 14 billion euros of fresh capital to keep them afloat and more time before they reopen even if a deal is reached with European creditors on Sunday, a senior Greek banker told Reuters on Friday.

Greece submitted new reform proposals late Thursday that creditors could evaluate as early as Friday. The parliament in Athens is also scheduled to vote on the proposals later in the day ahead of Sunday meetings of euro zone leaders.

Chinese stocks extended gains on Friday, jumping for a second day following government intervention amid hopes of a Greece deal. European stocks also advanced, with the DAX closing nearly 3 percent higher.

In domestic news, Fed Chair Janet Yellen said in prepared remarks the U.S. is still on pace for a rate hike this year and that fundamentals are solid and sees pickup in growth in the coming years.

"It confirms our belief that it will be a small hike and later this year," said Mariann Montagne, senior investment analyst at Gradient Investments. She expects a hike in November or December.

Yields extended morning gains with the U.S. 10-year note yield at 2.40 percent and the 2-year yield at 0.65 percent. German 10-year bund yields leaped to 0.89 percent.

Earlier, Boston Fed President Eric Rosengren said in a Reuters report that the central bank might hike rates later this year as long as inflation firms and Greece and other international wildcards do not get in the way. He added that negotiations over Greek debt and a slowing Chinese economy were among the possible disruptions that could delay the beginning of tighter U.S. monetary policy, though they hadn't altered expectations yet.

The U.S. dollar fell about half a percent, with the euro above $1.11.

"The likelihood of a Grexit has dramatically diminished," said Doug Cote, chief market strategist at Voya Investment Management. "Despite the volatility, despite the noise from Greece we're having good fundamental data coming out in (U.S.) housing. ... The fundamentals continue to drive this market forward."

In economic reports, for May jumped 0.8 percent, soundly topping estimates for the fastest pace of growth in six months. April's figure was unchanged, showing a 0.4 percent gain.

There are no major earnings due on Friday.

Stocks rallied sharply in the open Thursday but gave back the majority of their gains to close mildly higher as lack of resolution on Greece kept investors on edge.

"We were very oversold so it's very important that we rally next week," said Lance Roberts, general partner of STA Wealth Management. He's watching to see if the S&P 500 can hold 2,078.

He expects a rate hike in September unless the situation in China worsens.

"The one thing that trips up markets is the story no one is talking about," he said.

The Dow Jones Industrial Average closed up 211.79 points, or 1.21 percent, at 17,760.41, with Apple and UnitedHealth leading all blue chips higher.

The closed up 25.31 points, or 1.23 percent, at 2,076.62, with financials leading all 10 sectors higher.

The Nasdaq closed up 75.3 points, or 1.53 percent, at 4,997.70.

The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, fell below 17.

"There are a lot of things that can go wrong and I think the level of the VIX, even though it's come down, indicates we still have a lot of uncertainty," said Randy Frederick, managing director trading and derivatives at Charles Schwab.

About four stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 414 million and a composite volume of nearly 2 billion as of 2:30 p.m.

High-frequency trading accounted for 49 percent of July-to-date's daily trading volume of about 7.0 billion shares, according to TABB Group. During the peak levels of high-frequency trading in 2009, about 61 percent of 9.8 billion of average daily shares traded were executed by high-frequency traders.

Crude oil futures for August delivery settled down 4 cents at $52.74 a barrel on the New York Mercantile Exchange. Gold futures ended down $1.30 at $1,157.90 an ounce.

Read More

Gap closed half a percent lower after reporting a 1 percent drop in June same-store sales, more than the Thomson Reuters estimate for a 0.5 percent decline.

Barracuda Networks plunged 19 percent after reporting gross billings—a sign of future demand—that were well below Street forecasts. However, the cybersecurity and storage firm beat estimates by 1 cent with adjusted quarterly profit of 9 cents per share, with revenue also above estimates. However,

CNBC's Peter Schacknow contributed to this report.