NEW YORK — U.S. stocks closed higher on Monday, lifted in a late rally driven by earnings from Warren Buffett’s Berkshire Hathaway and broad gains across most sectors that helped the S&P 500 rebound from its largest weekly drop since 2012.

Warren Buffett’s Berkshire Hathaway Inc. gave the S&P 500 its biggest boost, helping it snap a two-day losing streak and adding 0.8 of a point to the benchmark index’s gain. The company said late Friday its second-quarter profit soared 41 percent to a record, which helped push its Class B shares up 3.1 percent to end at $129.72.

Despite a broad selloff last week, investors still have a bullish outlook on the markets, said Adam Hewison, president of in Annapolis, Maryland.

“If you look at the backdrop of turmoil around the world, whether it’s Ukraine, Israel or Palestine, there hasn’t been much downward movement in the markets. We had a bad last week in July, but I think that’s basically over with, and we’re probably going to continue going higher in the equity markets,” Hewison said.

Gains were partly offset by the S&P utilities sector index , which ended the day down 0.59 percent. It was the worst performer of the S&P’s 10 sectors.

The Dow Jones industrial average rose 75.91 points, or 0.46 percent, to end at 16,569.28. The S&P 500 gained 13.84 points, or 0.72 percent, to 1,938.99. The Nasdaq Composite added 31.25 points, or 0.72 percent, to close at 4,383.89.

Monday’s advance still left the Dow industrials in negative territory for the year. The blue-chip average ended Monday’s session just 7.38 points below its Dec. 31, 2013, close of 16,576.66, which was a record at the time.

The U.S.-listed shares of Tekmira Pharmaceuticals slipped on Nasdaq in a roller-coaster day for the tech-heavy index. Tekmira was viewed as a possible provider of a treatment for an Ebola virus outbreak in Africa, but then CNN reported a drug from privately held Mapp Biopharmaceutical Inc. had helped at least two patients.

Tekmira’s stock was up 18.3 percent on Nasdaq at one point, but finished down 7 percent at $13.26 a share. More than 9.8 million shares traded for the stock’s busiest day in its history.

Social media stocks performed well, with the Global X Social Media Index ETF up 1.6 percent. Groupon shares jumped 8.7 percent to $7.02. Facebook shares gained 1.6 percent to $73.51.

Over the next few weeks, the stock market is likely to be quiet with earnings season winding down and scores of traders leaving for vacation.

About 5.6 billion shares changed hands on U.S. exchanges on Monday, short of the 6.2 billion average for the last five days, according to data from BATS Global Markets.

Advancers outnumbered decliners by a ratio of about 19 to 12 on the New York Stock Exchange, while on the Nasdaq, about 17 stocks rose for every 10 that fell.