The Dow rose as much as 293.47 points, but a late-session sell-off in bank shares knocked the 30-stock index from its highs. Bank shares traded higher for most of the day after announcing buybacks and dividend hikes following the Federal Reserve's annual stress test.

Nike shares jumped more than 11 percent and reached an all-time high after the company reported quarterly earnings and revenue that beat expectations.

The Dow Jones Industrial Average rose 55.36 points to 24,271.41, with Nike outperforming. The gained 0.1 percent and closed at 2,718.37 as energy jumped 0.7 percent. The Nasdaq composite also advanced 0.1 percent to 7,510.30.

Stocks rose on Friday, the last trading day of the first half of the year, but still posted weekly losses as the underlying market sentiment was soured by anxiety over global trade frictions.

Traders work on the floor of the New York Stock Exchange on January 5, 2017, in New York City.

The first half of the year was fraught with volatility on Wall Street. The major indexes reached all-time highs in late January before concerns over rising interest rates knocked stocks off those levels. Equities recovered their footing following a strong earnings season and continuously strong economic data. But volatility returned to the market as President Donald Trump ratcheted up trade tensions between the U.S. and some its key partners.

“We’re clearly in a sideways market,” said Arian Vojdani, investment strategist at MV Financial. “The narrative — aside from strong economic data and good earnings — is not good.”

“Investors are sort of holding their cards to the chest because they want to see how this (trade spat) turns out,” Vojdani said.

The S&P 500 is up 1.7 percent this year, while the Dow is down 1.8 percent, marking its worst first-half performance since 2010. Meanwhile, the Nasdaq and the small-caps Russell 2000 have outperformed with gains of 8.8 percent and 7.1 percent. All four indexes rose on Friday, ending the first half on a high note.

But despite the gains, stocks indexes closed lower for the week as initial U.S. and Chinese tariffs are due to take effect next week. The Nasdaq dropped 2.4 percent for the week, its worst weekly performance in three months, while the Dow and S&P 500 fell at 1.3 percent each. The Russell 2000, meanwhile, dropped more than 2 percent.

The Trump administration is set to activate tariffs on Chinese goods worth around $34 billion on July 6, which is then widely expected to trigger a tit-for-tat response from Beijing. Trump has also alienated Canada, by levying tariffs on its steel and aluminum imports. Canada announced retaliatory tariffs on Friday that target $12.6 billion in U.S. goods.

Axios reported on Friday, citing sources, that Trump has repeatedly told top White House officials that he wants the U.S. to withdraw from the World Trade Organization.

The ongoing trade spat between the U.S. and China has sent market volatility higher this week, with the Cboe volatility index (VIX), surging 15.6 percent.

"For the stock market, the rest of the year could be quite exciting, in both a positive and a negative sense," said Brad McMillan, chief investment officer at Commonwealth Financial Network. "I expect the U.S. equity markets to end the year with moderate appreciation from levels at the end of December—around 3,000 for the S&P 500 as a base case."

"In the nearer term, the Trump administration’s trade policies have the potential both to disrupt supply chains and increase costs, which would certainly affect financial markets," said McMillan.

— CNBC’s Thomas Franck contributed to this report.