(AP) -- The S&P 500 index briefly traded at an all-time high Tuesday just as the U.S. stock market's bull run came closer to becoming the longest on record.
The market's benchmark index eked out a slight gain, closing a little below the high mark it set in January. The rally pushed the Russell 2000 index of smaller-company stocks to a record high.
The current bull market, which began in 2009, is on track to become the longest in history on Wednesday, surpassing the bull run of the 1990s.
Tuesday's gains were driven by strong earnings by homebuilders, retailers and other companies.
"That we got to these levels in January was a big surprise, more so than we're back there now," said Bob Doll, chief equity strategist at Nuveen Asset Management. "We've had a mildly higher market after the correction on the back of these amazing earnings."
The S&P 500 rose 5.91 points, or 0.2 percent, to 2,862.96. The Dow Jones Industrial Average gained 63.60 points, or 0.2 percent, to 25,822.29. The Nasdaq composite added 38.17 points, or 0.5 percent, to 7,859.17. The Russell 2000 picked up 19.35 points, or 1.1 percent, to 1,718.05. It's last all-time high was set June 20th.
Shortly before 1 p.m. Eastern Time, the S&P 500 briefly crossed above its latest closing high of 2,872 set on Jan. 26. The market took a steep plunge immediately after that, in early February, and has been mostly clawing higher since then, with some bumps along the way, thanks to a still-recovering economy and a boom in corporate profits.
Stocks have been buffeted by concerns about mounting trade tensions this spring and summer, particularly with China. Signs of potential progress have helped stocks rally in recent weeks. S&P Dow Jones Indices, which compiles the S&P 500, says that on Wednesday, the current bull market become the longest in history.
"Earnings are still going to carry the market higher, but the trade issue holds us back for stocks keeping up with earnings," Doll said.
Investors have had much to cheer about when it comes to company earnings this year, and the second-quarter reporting period has been no exception. Of the 93 percent of the companies in the S&P 500 that have reported quarterly results, 62 percent delivered earnings and revenue that beat analysts' forecasts, according to S&P Global Market Intelligence.
"Earnings season was phenomenal and that removed one worry," said Craig Birk, chief investment officer at Personal Capital. "When people are just looking at companies and just looking at economic fundamentals, they feel good about things."
Investors cheered the latest batch of strong company earnings Tuesday.
Traders sent homebuilder shares higher after Toll Brothers reported earnings that came in well ahead of what analysts were expecting. The luxury builder vaulted 13.8 percent to $39.52. Other homebuilders also got a boost. Lennar gained 4.2 percent to $53.26, while PulteGroup added 5.5 percent to $29.67.
TJX also delivered quarterly results that impressed investors, who sent shares in the operator of T.J. Maxx, Marshalls and other discount retail chains 4.7 percent higher to $106.46.
Medtronic gained 5.7 percent to $95.17 after the medical technology company's latest quarterly report card also beat Wall Street's projections.
Discount brokers fell sharply after CNBC reported that JPMorgan Chase will offer free online trading. ETrade fell 4.4 percent to $58.56. Charles Schwab lost 2.4 percent to $50.17. TD Ameritrade slumped 7.1 percent to $55.88.
J.M. Smucker fell 6.6 percent to $108.20 after the maker of Jif peanut butter, Crisco cooking oil and other products reported quarterly results that fell short of analysts' estimates. The company also trimmed its outlook for the year.
U.S. benchmark crude rose 1.4 percent to settle at $67.35 per barrel in New York. Brent crude, the standard for international oil prices, gained 0.6 percent to close at $72.63 per barrel in London.
Bond prices fell. The yield on the 10-year Treasury rose to 2.84 percent from 2.82 percent late Monday.
The dollar rose to 110.40 yen from 110.23 yen late Monday. The euro strengthened to $1.1574 from $1.1467.
Gold rose 0.5 percent to $1,200 an ounce. Silver added 0.7 percent to $14.77 an ounce. Copper gained 0.9 percent to $2.71 a pound.
In other energy futures trading, heating oil rose 0.5 percent to $2.12 a gallon. Wholesale gasoline gained 0.1 percent to $2.02 a gallon. Natural added 1.3 percent to $2.98 per 1,000 cubic feet.
Major indexes in Europe finished mostly higher. Germany's DAX added 0.4 percent, while France's CAC 40 climbed 0.5 percent. Britain's FTSE 100 slipped 0.3 percent.
In Asia, Japan's benchmark Nikkei 225 rose nearly 0.1 percent, while Australia's S&P/ASX 200 lost nearly 1 percent. South Korea's Kospi rose 1 percent. Hong Kong's Hang Seng climbed 0.6 percent. Shares were higher in Taiwan but fell in Singapore.