It was one of the darkest periods of the market slump. The global economy was showing fresh signs of slowing, and crude prices were collapsing so steeply that virtually every well in America was unprofitable.

But when Diamondback Energy went out to raise $226 million worth of new stock that week in the middle of January, the oil and gas company found more buyers than it could accommodate. It had to nearly double the amount of shares it sold, to four million.

Since Diamondback issued equity that day, the company’s share price has increased more than 29 percent.

Across the oil industry, investors have been placing their bets that prices have hit bottom. Risk-seeking investors like hedge funds and firms, which were already lending money to struggling energy companies at high interest rates and onerous terms, are among those to have smelled opportunity in a potential comeback.

Yet some of the biggest and most successful bets on oil are being wagered by mutual funds and index funds that are scooping up plain-vanilla equity offerings like Diamondback’s deal in January.

With production slowing, in recent weeks. On Friday, the International Energy Agency declared in a report that “there are signs that prices might have bottomed out,” citing progress among leading oil producing nations about a production freeze and supply outages in Iraq, Nigeria and the United Arab Emirates.

There is still a way to go before a full recovery. Many analysts caution that the recent recovery in prices could easily reverse itself. They argue that the tentative agreement between Saudi Arabia, Russia and a few other producing countries to freeze output at January levels will probably make little difference to global supplies.

On Monday, fresh worries about supplies emerged as analysts expressed more skepticism about whether Iran would abide by a freeze. The United States oil benchmark fell 3.4 percent, to $37.18 a barrel on Monday.

Prices, however, are still more than 40 percent higher than their lows in mid-February. And that has made investors more optimistic about energy.

Graphic | How Oil Stocks Are Performing

Oil and gas companies have issued about $11 billion in equity just in the two first two months of this year, according to the data provider Dealogic, putting the sector on pace to eclipse the $24 billion that was raised last year.

Among the companies that have been able to secure capital from the equity markets are many midsize exploration and production companies that have been leaders in the shale revolution, like Marathon Oil, Devon Energy, Pioneer Natural Resources, Concho Resources, Parsley Energy, RSP Permian and Diamondback.

The stock offerings are helping the companies maintain their oil fields, meet payrolls and keep up with debt payments at a time when production and revenue are falling.

While that adds flexibility for many of the strongest companies, more than 100 mostly small oil and gas companies have been forced into bankruptcy in recent months, as banks call in credit lines and broadly curb lending to the industry.

“The market sees the haves and the have-nots,” said Robert Santangelo, co-head of Credit Suisse’s equity capital markets in the Americas. “And has done a good job allocating capital to survivors.”

Since the start of 2015, Credit Suisse has netted $126 million in revenue from underwriting equity deals in the oil and gas sectors, including the Diamondback offering, more than any other investment bank, according to Dealogic.

Many of the equity issuers are active in the Permian Basin of West Texas and New Mexico, the source of more than 20 percent of the nation’s production, which helps explain why the field’s output has been more resilient than virtually any other field in the country. Production in early February exceeded two million barrels a day, up from 1.4 million barrels a day two years ago.

Pioneer Natural Resources, for instance, announced in January a $1.4 billion stock offering intended to help fund its 2016 capital program, heavily weighted in the Permian Basin.

Soon afterward, the company decided to reduce drilling when oil prices suddenly dropped by $10 a barrel. The cash from the added equity offering, however, gives the company one of the strongest balance sheets in the industry to increase production when prices stabilize and go up.

“If prices recover mid-2016, if they recover late 2016, if they recover early 2017, we have tremendous firepower to start up faster than anybody else,” Scott D. Sheffield, Pioneer’s chief executive, said in a recent conference call.

Multimedia Feature | Oil Prices: What’s Behind the Drop? Simple Economics The oil industry, with its history of booms and busts, is in a new downturn.

Even the strongest companies are not immune to pressure, however. Diamondback, for instance, had to discount its stock 3.5 percent from the market price when it issued new shares in January.

Rebounding oil prices have at least temporarily quelled speculation by analysts that many more companies will go bankrupt or look to merge with larger competitors. There are tentative signs that the oil market is beginning to regain its balance between new supply and demand, but there is still a large glut of oil worldwide.

United States oil production is dropping fast, by more than a half million barrels a day since last spring, and that decline should quicken: The oil rig count has fallen by roughly 75 percent from the peak in 2014. This is the first time since the 2009 recession that the rig count has fallen below 400 rigs.

Now, with weather warming and refineries beginning their spring maintenance for summer blends, surpluses in gasoline inventories are beginning to ease.

Crude production is also falling in Nigeria and Iraq as a result of insurgent attacks on pipelines. A wild card is Iran, which has been slow to meet its promise of exporting an additional 500,000 barrels of crude a day now that nuclear sanctions have been lifted. Nevertheless, tankers full of Iranian oil have left port in recent days destined for Spain, France, Romania and Tanzania.

The ability of American companies to go to the equity market for capital is helping them finance production. And once the price of oil rises above $45 a barrel, there could be a revival of at least some of the dropped production. Many companies are waiting until oil and gas prices recover to put wells already drilled on line or fix wells that have been sidelined.

“The equity raise isn’t available for everybody out there,” said Vance Scott, oil and gas leader for the Americas at Ernst & Young transaction advisory services. “If we see a firming of oil prices, in the $40 to $45 range,” he added, “there are companies out there with good enough acreage position and cost structure that they can get the returns that they want.”

Production costs have declined almost as steeply as crude prices because service companies have been forced to lower their rates and drillers have developed more efficient well designs. Rystad Energy, a Norwegian-based consulting firm that studies oil fields around the world, has estimated that the break-even price for production in the main shale fields of North America declined by more than 40 percent between 2013 and 2015.

Although the future for oil prices remains uncertain, experts say the recent rise – if sustained — could mean more equity offerings, but only for strong companies.

Mr. Santangelo, the Credit Suisse banker, says that while oil prices may still be volatile over the next few months, the shale industry is proving resilient.

“Coming into this you heard shale would be the first to go,” he said. “That is not happening. What’s emerging is a healthy shale industry that is very competitive in the global market.”

Correction: March 16, 2016

An article on Tuesday about growing optimism among investors that the energy market is poised for a rebound misstated the amount by which Iran has promised to increase its oil exports. The plan is for an additional 500,000 barrels a day, not 500 million.