Wall Street wrapped up a roaring June and first half of the year as investors cheered the prospects of easier monetary policy from the Federal Reserve and awaited clarity on U.S.-China trade relations.

The Dow Jones Industrial Average rallied 7.2% this month, notching its best June performance since 1938, when it surged 24.3%. Caterpillar, Apple and Goldman Sachs drove the Dow's gains in June, rallying more than 12% each.

The posted its best first half of a year since 1997, soaring 17.3% and reaching an all-time high. All 11 of the S&P 500 sectors rose in the first half of the year, with tech rising more than 26% to lead the gains. Energy was the market's laggard in the first half, rising just 7.1%.

One subset of the technology space that shined this month was semiconductor stocks. The VanEck Vector Semiconductor ETF (SMH) — one of the most widely followed ETFs for chip stocks — skyrocketed more than 12% in June, notching its biggest one-month gain since September 2010.

Semiconductor stocks were coming off a 15.5% plunge in May, however, as trade tensions between China and the U.S. ratcheted up. Investors turn their eyes to the G-20 summit Osaka, Japan as Chinese President Xi Jinping and President Donald Trump are scheduled to meet and discuss trade.

Gold also surged more than 7% in June as the dollar dropped and the Fed opened the door for a potential rate cut in July. The precious metal's gain this month was its biggest since June 2016, when it jumped more than 8%.

Oil prices, meanwhile, got a boost amid rising tension between Iran and the U.S. Tensions between the two countries escalated after a U.S. drone was shot down earlier this month. Iran claimed the drone was flying over Iranian airspace, violating international law, while the U.S. disputed those claims.

West Texas Intermediate futures surged more than 9% in June, its biggest one-month rally since January, when it rose 18.5%.

Subscribe to CNBC on YouTube.