Producers of metals, grains and other raw materials rose, but not by as much as the broad market, as the U.S. dollar hovered around 52-week highs.

Gold futures rose 1.1% to $4068.30 a troy ounce, testing the psychologically significant $4,000-per-ounce level early in the session.

For the second quarter, gold tumbled 13%, the largest quarterly loss on record as hedge funds backed out of the "dollar debasement" trade. This was a bet that the Federal Reserve would deplete the relative value of the U.S. dollar by cutting rates under pressure from President Donald Trump. Now, traders have flipped their bets to anticipation of Fed rate hikes, buoying the dollar and hurting dollar hedges such as gold and bitcoin.

The U.S. dollar tested 52-week highs Wednesday after Fed Chair Kevin Warsh refused to comment on his rate stance at a European Central Bank event.

"Warsh sounded dovish at the ECB Forum, arguing that inflation risks have faded, especially around inflation expectations," said Sonu Varghese, chief macro strategist at financial consulting firm Carson Group.