After lazing about for most of the day, the S&P 500 did a sprinting finish in the final hour to end at a new record high.
The S&P 500 gained just over two points to end at 1,959.48. That was enough to surpass Wednesday's all-time high.
The Dow Jones industrial average also edged higher, but the Nasdaq lost a few points.
Stocks soared Wednesday after Federal Reserve Chair Janet Yellen signaled that interest rates will remain low. But the rally lost momentum Thursday as investors shifted their attention to the gold market.
Related: Fed says job market is getting a bit better
All that glitters: Gold futures gained over 3.5% to trade at $1,318 per ounce, the highest level since April. Investors who believe Fed policy will undermine the dollar view gold as an alternative currency. In addition, gold prices often rise during times of political and military uncertainty.
Oil prices moved slightly higher after President Obama said he is prepared to send military advisers to Iraq, but he added that America was not returning to a combat role in the country.
The oil market has been volatile recently as Iraqi forces are battling insurgents for control of towns and cities not far from Baghdad. Iraq is the second-largest producer in the Organization of the Petroleum Exporting Countries.
Related: Gas prices are rising a little, but there's an oil glut coming soon
Stocks that are tanking -- American Apparel, Coach, Amazon, Facebook, a for-profit college: Shares in American Apparel (APP) rose after the company announced overnight that it fired its controversial CEO, though it didn't say why. Its shares, which topped $15 as recently as 2007, now trade for less than $1. Sources told the New York Post that the move could set the stage for American Apparel to be sold.
Coach (COH)shares plunged over 9% after the maker of leather goods predicted a prolonged slump in sales and announced plans to close more stores.
Corinthian College, (COCO) a for-profit education company, warned that it may need to shut down as the government cracks down on its attendance and grading practices. Shares of Corinthian, which operates 97 schools across the country, plunged more than 60%.
Facebook (FB) suffered an outage that prevented users posting to the social media site "for a brief period of time." (Gasp!)The stock fell nearly 2%.
Related: CNNMoney's Tech 30 Index up today and year to date
Elsewhere in the smartphone space, Amazon (AMZN) shares edged lower after the online retailer unveiled the Fire Phone, a high-end, 3-D smartphone. It is the first smartphone Amazon has produced on its own.
Drug store chain Rite Aid (RAD) said net income fell in the latest quarter, sending its shares down 4%.
Stocks that are surging -- BlackBerry, Kroger supermarkets: BlackBerry (BBRY) is back from the dead...again. The ailing smartphone pioneer reported a smaller-than-expected loss, sending its stock up more than 9.5%. BlackBerry stock is up 24% so far this month, bouncing back from a rough patch during April and May.
Related: Meow! BlackBerry has more lives than a cat
Kroger (KR) shares jumped over 5% after the grocery store chain reported strong results and boosted its outlook. The stock hit an all-time high over $50.
Markit IPO today: Markit (MRKT), which provides information on bonds and derivatives for traders and is considered a rival of sorts to Bloomberg, said late Wednesday that it had raised $1.3 billion in an initial public offering. The stock, which was priced at $24 a share, gained more than 11% after it began trading on the Nasdaq.
Related: Fear & Greed Index still extremely greedy
Most European markets closed higher. Despite the ongoing crisis in Ukraine, Russian stocks have been on a tear. The benchmark Micex index has erased its losses for the year and the rubel is also back near pre-crisis levels. Asian markets were mixed.