Energy companies are raising money again from Wall Street at superlow borrowing costs, thanks in part to higher oil prices. The one thing most investors don’t want them to do with it is pump more crude.

Speculative-grade energy companies, including oil producers, pipeline operators and refineries, have issued bonds in the U.S. at a record pace this year, raising about $34 billion so far, according to LCD, a unit of S&P Global Market Intelligence. Cash is primarily heading toward riskier borrowers in the shale patch, which by this time last year had raised about half as much from bond issuances.

Laredo Petroleum Inc. on Tuesday issued $400 million of bonds due for repayment in 2029 with a coupon of 7.75%. The Oklahoma-based oil-and-gas producer plans to use the money in part to pay off other debts.

The willingness of investors to finance shale oil producers marks a shift from 2019 and the first half of 2020, when years of poor returns and then the pandemic caused funding to dry up.

Wide-open capital markets introduce a new wrinkle into the debate over the direction of crude prices, which already have jumped about 49% this year to roughly $72 a barrel in the U.S. The ability to borrow at relatively low rates has put U.S. oil companies on surer financial footing, ensuring there are plenty of producers that could open the taps if needed to keep crude prices in check.

The catch: Investors want to see companies repairing their balance sheets and delivering to creditors and shareholders rather than plowing money into new wells.

The restraint demanded by investors stands in contrast to previous periods of breakneck growth in U.S. production. It raises the prospect that the nation’s output—which has been largely flat this year—may not rise to offset a recovery in demand as major economies roll back coronavirus restrictions.

Companies are refraining from deploying money to raise output, which in turn is tightening the balance between supply and demand, said Lex Maultsby, a managing director for leveraged finance at Bank of America. “Most of the debt financings are principally extending debt maturities and not being used to fund…production growth.”

Asset manager Janus Henderson Investors has bought bonds of energy companies in recent months, including newly issued debt, because bond prices looked low and primed to rise as oil markets rallied. “In order to get the support of debt markets, they had to get more conservative around their balance sheets,” said portfolio manager Tom Ross.

The stream of cash isn’t indiscriminate, however: Mr. Ross said companies that aren’t preparing for a world of lower hydrocarbon consumption will increasingly struggle to access funding. Investors are looking to lend to companies that can make money with crude prices at or below $50 a barrel, energy bankers say.

Strong investor demand has led to tumbling borrowing costs. The gap between yields on speculative-grade U.S. dollar bonds issued by energy firms and those on supersafe Treasurys—a gauge of how risky investors perceive company debt to be—fell to 3.32 percentage points this month. That was the lowest spread since July 2014, according to Bloomberg Barclays data.

The drop in borrowing costs also reflects changes within the world of junk-bond issuers. Defaults last year culled some of the riskiest bonds from the crop of speculative-grade energy companies. Some bigger, higher-quality issuers fell into the bucket after downgrades by credit-ratings firms.

Wall Street’s fresh embrace of the oil patch came when successful Covid-19 vaccine trials last November spurred a rebound in energy prices. Many money managers are encouraged by companies’ single-minded focus on reducing debt levels. Comparatively high yields on energy bonds also attracted investors.

When U.S. oil production boomed a few years ago, companies fueled growth by raising money from Wall Street. In contrast, about 88% of the industry’s high-yield bond sales this year have gone toward paying down existing debt to lower interest costs or extend maturities. That compares with 52% to 65% from 2012 to 2015, the LCD data show.

Pioneer Natural Resources Co. and Diamondback Energy Inc., for example, both raised more than $2 billion to refinance debt following large acquisitions.

SHARE YOUR THOUGHTS

What impact will Wall Street’s preference for green energy have on oil and gas companies? Join the conversation below.

Hundreds of companies had been tipped into bankruptcy in the oil busts of the past decade, underscoring how heavily debt could weigh on the capital-intensive business when used to fuel growth, said Ken Settles, a managing partner at SailingStone Capital Partners LLC.

“There’s a better appreciation in the capital markets for the vulnerabilities of the shale oil business,” Mr. Settles said.

Write to Joe Wallace at Joe.Wallace@wsj.com and Collin Eaton at collin.eaton@wsj.com