High-yield bonds, sometimes called “junk,’’ carry lower ratings and pay more interest than the safest bonds, because there is more risk that these borrowers won’t be able to repay the debt. Investors profit by betting on the companies they believe will pay.

The $21 billion Loomis Sayles Bond Fund is one of the best in Morningstar’s multisector bond category, up about 6 percent this year and 10 percent annually over 10 years. Those are the kinds of numbers stock investors used to hope for. Gaffney said the Loomis fund has done well because of its long-term positioning and by maximizing its exposure to riskier high-yield corporate debt at about one-third of the portfolio. “It is a good time to take risk but you have to do your homework,’’ she said.

“When I look ahead, for your typical bond fund that doesn’t have broad flexibility, I think they’re going to be very challenged to provide the types of returns that we’ve seen the last 10 years,’’ said Kathleen C. Gaffney, vice president at Loomis, Sayles & Co., a Boston bond management firm.

Bond managers don’t expect to see another period like this for a long time.

And it doesn’t look much prettier over time, because of the losses sustained in the 2008 financial crisis. You have to go back five years to average 1 percent a year, and as you go back 10 years, gains on the average stock fund are still less than 4 percent annually.

US Treasury bonds, that is. Meanwhile, diversified stock funds on average have lost 5.4 percent of their value in 2011 so far, courtesy of the recent debt drama.

“After the whole debt ceiling debacle ended, again investors focused on Europe and real problems,’’ said Payson F. Swaffield, chief income investment officer at Eaton Vance Corp. in Boston. “The market was basically saying, despite the downgrade, the US is still the place to be.’’

Bonds are on fire even after Standard & Poor’s downgrade last month of US debt from its AAA rating. It was stocks that took a beating after that action, not bonds.

The numbers are startling in some cases: Long-term government bond funds are up 19 percent so far this year, and corporate bond funds are up as much as 14 percent. Even Massachusetts municipal bond funds are up an average of 6.8 percent, according to Morningstar Inc. , the Chicago fund-tracking firm.

That’s right, for a whole decade it would have been better to own bond funds instead of the stock funds in which most Americans stash at least half of their retirement funds. In almost every category - government, corporate, high-yield, emerging markets, even ho-hum municipals - bond funds outperformed the typical stock fund.

It’s enough to make stock investors weep. Hands down, bond funds have done far better than the average stock portfolio, and not just this year, but for 10 years.

Bonds have done well generally over the past decade because interest rates have been falling, and their prices have been rising. When rates eventually rise again - and they will, because they are now at record lows - bonds will fall in value. But the big question is when that will happen. With the economy moving slowly, the Federal Reserve has pledged not to raise rates for two years. Bonds could be more reliable than stocks for another year or two, portfolio managers said.

“Right now, high-quality bonds are clearly the place to be,’’ said Mihir Worah, a managing director at Newport Beach, Calif.-based PIMCO, the bond fund management firm, and head of its Real Return portfolio management team.

They will probably be worth the risk for at least six to nine months, he said, especially compared with stocks, “which aren’t going to do too well either, or cash, which is going to give you nothing in the bank.’’

The most promising bond categories in the near term, investment managers said, are municipal, emerging market, and inflation-protected.

Municipal bond funds, which buy bonds issued by states, municipalities, counties, and other governmental entities and offer tax benefits, are having a big year. They are up 6.8 percent on average in Massachusetts, after getting beaten up last year amid predictions of massive state bond defaults - forecasts that did not come true, for the most part.

Eaton Vance’s Massachusetts Municipal Income fund is ranked number one in the state by Morningstar, with an 8.4 percent gain for 2011.

“The whole category has proved to be one of the best-performing asset classes, if not the best, and certainly better than equities,’’ Eaton Vance’s Swaffield said. He sees the group continuing to do well, even as fears swirl about debt defaults in Greece and elsewhere in Europe.

“The municipal bond market in the US is somewhat isolated from that,’’ he said. “It’s this market that’s on an island.“

Emerging market bond funds also hold opportunities. Fund managers say they are looking to developing markets that are experiencing more growth than the United States or Europe and that do not have the debt baggage Western nations are struggling with. As those countries cut interest rates, Gaffney of Loomis Sayles said, their bonds should perform well.

“You need to go where the growth is,’’ she said. “We just saw Brazil cut rates . . . we’re seeing how some of the developing world is looking at reining in inflation.’’

Inflation, which has been all but absent in this country for two decades, has recently been creeping up, due to higher energy and commodity prices. The US inflation rate in July was 3.6 percent.

Inflation-protected bonds, which have soared in value this year - up nearly 10 percent, on average - could be hurt when interest rates rise, managers said. But they will do better than other long-term government bonds because their principle is adjusted for inflation, they said.

Generally, however, this decade of great returns for bonds is coming to a close.

Said PIMCO’s Worah: “Over the next 10 years, bond returns aren’t going to be that great.’’

Steven Syre of the Globe staff contributed to this report. Beth Healy can be reached at bhealy@globe.com.

© Copyright 2011 Globe Newspaper Company.