Investors have poured more money into municipal bond funds so far this year than they have in decades, driving borrowing to fund new bridges, sewers and other state and local projects to a second-straight 10-year high. 

Municipal bond funds now hold an unprecedented 24% of outstanding debt compared with 16% five years ago, according to Federal Reserve data. The move marks the latest step in a fundamental shift away from a buy-and-hold market where individual investors quietly collect interest year after year. 

The...

Investors have poured more money into municipal bond funds so far this year than they have in decades, driving borrowing to fund new bridges, sewers and other state and local projects to a second-straight 10-year high. 

Municipal bond funds now hold an unprecedented 24% of outstanding debt compared with 16% five years ago, according to Federal Reserve data. The move marks the latest step in a fundamental shift away from a buy-and-hold market where individual investors quietly collect interest year after year. 

The record levels of borrowing and investing in 2021 are evidence that investors have moved well past their early worries the pandemic would drive a wave of municipal defaults and bankruptcies. Buoyed by stimulus funds, state and local governments issued $301.9 billion of debt for new projects as of Dec. 21, the most in at least a decade. 

Meanwhile, investors plowed $64 billion into muni mutual and exchange-traded funds through Dec. 15, according to data from Refinitiv Lipper, more than they ever have during that period since tracking began in 1992. That includes $22 million into high-yield funds that hemorrhaged cash last year.

“Generally there’s a better credit environment, you have lower supply [and] more demand, and then you just have investors who are willing to take on more risk to replace the yield that they previously got on their high-grade bonds,” said Eric Friedland, director of municipal-bond research at asset manager Lord Abbett.

Bonds issued by state and local governments are particularly precious to investors because they carry interest payments usually free from federal, and often state, taxes. Expectations for possible tax increases under a Democratic administration likely stoked investors’ appetites, Mr. Friedland said.

The S&P Municipal Bond Index has a total year-to-date return of 1.73%, including price changes and interest payments.  That compares with minus 1.72% for the S&P U.S. Treasury Bond Index and minus 1.62% for the S&P U.S. Investment Grade Corporate Bond A Index.

High-yield municipal bonds racked up more-substantial gains as investors abandoned their fears of default, with the S&P Municipal Bond High Yield Index returning 6.67% in the year to date.

The government and nonprofit borrowers that issue bonds in the nearly $4 trillion municipal market are generally in better financial shape than they were last year, according to analysts and financial reports. Tax collections and stimulus funds have buoyed municipal balance sheets. The federal infrastructure package signed into law last month could lead to additional money for capital projects. 

The median number of days worth of cash on hand was up 11% this year for 173 nonprofit hospitals that have filed their 2021 financial statements, according to Merritt Research Services. For airports that have filed statements, median days cash on hand increased by 22% and for private colleges and universities, a similar cash metric increased 12%.

“These sectors have built up significant cash and reserves that they didn’t have at the onset of the virus in 2020,” said Richard Ciccarone, Merritt’s president and chief executive. Still, he said, “not everybody’s coming back in good shape.”

Defaults, a rarity in the muni market, remain higher than during the pre-pandemic period, though they have fallen from last year, according to Municipal Market Analytics. Some borrowers have fared particularly badly. There have been 32 defaults to date this year among assisted living and other senior housing borrowers, the most since the firm’s record-keeping began in 2009. 

Some state and local governments also remain on shaky ground, using bond money to plug budget gaps or relying on stimulus funds to paper over financial problems. Towns across the U.S. this year resorted to pension obligation borrowing, using a record-breaking amount of debt to top up retirement funds in the hopes that market returns will outpace interest costs.

Even with borrowing for new projects at a 10-year record, total debt issuance fell short of some expectations. Citigroup twice revised its forecast for total 2021 issuance downward, after Congress declined to include two bond programs in the infrastructure bill. “We could not convince our policy makers,” said

Vikram Rai, Citigroup’s head of municipal strategy. 

Including refinancing deals, municipal borrowers had sold a total of $454 billion as of Dec. 21, also at least a 10-year record.  

Cities and states could probably sell roughly $100 billion more of bonds without driving down prices, according to an analysis of lending capacity by Municipal Market Analytics. The mismatch between supply and demand grew after the 2017 tax overhaul prohibited the use of tax-exempt borrowing for early refinancing while simultaneously making tax-free yield more precious to some investors by capping the state and local tax deduction.

While muni bond rates remain at historic lows, the tax exemption can create significant value in high-income households. A 20-year AA-rated municipal bond yielded 1.49% as of Dec. 21, according to Refinitiv Municipal Market Data. For someone in the top tax bracket to get that kind of income on a taxable security, it would need to yield about 2.5%, according to data from asset manager Nuveen.

Investor money has poured in mainly through funds, bringing mutual and exchange-traded muni fund holdings to more than $1 trillion as of Sept. 30, according to Federal Reserve data.

At the same time, the amount of municipal debt held by brokers and dealers has shrunk to $12.1 billion, a 26% drop from 2019. That makes the market increasingly vulnerable to the kind of free fall experienced in March 2020, when investors scared of how the pandemic could affect municipal credit fled muni bond funds, triggering a liquidity crisis and sending prices plunging.

“With dealer positions down, and mutual funds up, there’s less of a relief valve,” said Patrick Brett, head of municipal debt capital markets at Citigroup and chair of the Municipal Securities Rulemaking Board, the muni bond industry’s self-regulatory organization.

Write to Heather Gillers at heather.gillers@wsj.com