Q: My grandfather recently passed away and left me a stock portfolio. I want to leave it alone for the most part but may sell some of it in order to pay off debt. If I did, how much tax would I have to pay?

The first question is whether the stock you inherited is in an IRA or if it's in a standard (taxable) brokerage account. If the stock is in an IRA, the answer is easy -- Roth IRA withdrawals are generally tax-free while traditional IRA withdrawals are considered ordinary taxable income, regardless of how much profit was made on the stocks in the account.

On the other hand, in a taxable brokerage account, the answer is a bit more complicated.

First, when you inherit stock, your cost basis of the shares is set at the stock's value at the date of death, not the date when the deceased originally bought it. So, if your grandfather paid $10 per share for a stock and it was worth $40 when he died, the IRS would calculate your capital gains as if you had paid $40.

Second, sales of inherited stock are always treated as long-term capital gains, no matter how long you wait to sell.

Here's the takeaway: Inherited stock is generally treated favorably for tax purposes. Not only will you not have to pay tax on any gains that occurred during your grandfather's life, but you'll also benefit from relatively low long-term capital gains tax rates. So if you sell the stock shortly after you inherit it and before it has appreciated much, your tax bill could be rather minimal.

The Motley Fool has a disclosure policy.