Exxon Mobil is the world’s largest publicly-traded oil-and-gas company with a market capitalization of $407.2 billion. Berkshire’s stake was valued at $3.45 billion as of Sept. 30, and represents less than 1% of Exxon Mobil’s 4.4 billion shares outstanding.

The stock was likely picked by Mr. Buffett himself, given the size of the investment. The billionaire investor has said he is in charge of investment decisions for Berkshire’s multibillion-dollar stock holdings, while his two investment managers Todd Combs and Ted Weschler buy and sell smaller positions.

Mr. Buffett hired the two managers in 2010 and 2011 to help run Berkshire’s investment portfolio as part of his succession plan. Each now manages assets worth about $6.5 billion, up from $5 billion in March, reflecting increases in the value of stocks they have picked as well as greater funds to invest, people familiar with the matter said.

Mr. Buffett has had mixed luck with his bets on energy companies. In his 2008 letter to shareholders, he rued Berkshire’s large purchase of ConocoPhillips stock when oil and gas prices were near their peak, just before they nosedived. “Even if prices should rise… the terrible timing of my purchase has cost Berkshire several billion dollars,” he wrote.

Berkshire owned about $940 million of the company’s stock as of Sept. 30, having cut its stake by more than $500 million from the previous quarter.

In 2007, Berkshire bought $2 billion worth of bonds of Texas electric utility Energy Future Holdings, which he later called a “big mistake.” Mr. Buffett said in his 2012 letter that Berkshire wrote down the value of much of that holding as natural gas prices remained depressed.

Mr. Buffett’s bet on Exxon comes at a relative low point for the energy titan. Its stock hasn’t budged this year, while shares of rival Chevron Corp. have gained about 9%.

Exxon’s oil and gas production has dwindled in recent years, and profits have been diluted by a big bet on U.S. natural gas just before prices for the fuel plunged.

The Irving, Texas based company is spending at historic levels as it tries to boost its output. It has shelled out more than $100 billion since 2011 on massive projects, from drilling in Russia’s icy waters to building plants in Papua New Guinea to chill natural gas into liquid form for export.

This heavy spending has left Exxon with less spare cash to distribute to shareholders. The company has long bought its own shares as a way of increasing their value by making them scarcer, but is repurchasing them at the rate of $3 billion a quarter, down from $5 billion a quarter in 2011 and 2012.

Exxon’s capital spending, dividend payments and share buybacks exceeded its cash flow in the third quarter of 2013. The company added $2 billion in debt in the period.

But there are signs that Exxon is coming out of its slump. The company’s third-quarter oil-and-gas production increased slightly from a year earlier, and its profits from selling the fuels also increased.