One of the most appealing features of a traditional individual retirement account (IRA) is that you don’t pay income tax on any investments until you withdraw the money, right? Well, in some cases, wrong!

Many investors are running into surprise tax bills because instead of limiting their IRAs to stocks, bonds and mutual funds, they have added so-called alternative investments. These include master limited partnerships (MLPs), which generally own and operate oil and gas pipelines, as well as hedge funds and private-equity funds. Many IRA custodians, including Fidelity and Charles Schwab, now allow customers to hold such investments in their accounts.

When these investments generate income from businesses they own and pass it along to investors, the IRS considers the money taxable even if it is in a traditional IRA or a Roth, Simple or SEP IRA. Such income is known as “unrelated business taxable income” (UBTI). In addition, income you get from any real estate you own that is debt-financed qualifies as UBTI.

How UBTI affects your taxes: If your IRA earns more than $1,000 in UBTI in any calendar year, a tax return for your IRA must be filed. UBTI is subject to the tax rate for trusts. The maximum trust tax rate of 39.6% is triggered at $12,500 in income. The IRA also may be required to file quarterly estimated tax payments the following year. And even if the UBTI is taxed when it is generated, if that income is in a traditional, Simple or SEP IRA (but not a Roth), it will be taxed again at your personal income tax rate when it is withdrawn from the IRA.

Self-defense: If you plan to own an alternative investment in an IRA…

Discuss potential purchases with your tax adviser. You need to understand how much UBTI the investment may generate based on past years and keep a certain amount of liquid assets in your IRA because any taxes due must be paid directly from the IRA.

If the investment generates UBTI, make sure that the custodian that oversees the IRA files a tax return for the IRA and remits any taxes the IRA owes. Otherwise, the IRA could be hit with substantial late-payment penalties.