Tax Implications of Selling Stock to Buy a House

The tax implications of selling stock to buy a house come down to one rule: every dollar of profit is taxable in the year you sell, and it does not matter that you are using the money for a home. Federal capital gains tax runs from 0% to 37% depending on how long you owned the shares and your total income for the year. There is no rollover, no exemption, and no like-kind exchange that lets you shift stock gains into real estate tax-free.

What you can control is timing, which shares you sell, and whether you pair the sale with losses elsewhere in your portfolio. Those choices often make a five-figure difference on a large liquidation.

How Long You Held the Stock Decides the Rate

Shares sold within a year of purchase produce short-term capital gains, taxed at ordinary income rates that run from 10% to 37% for 2026.1Internal Revenue Service. Federal Income Tax Rates and Brackets Sell nine months after buying, and more than a third of your profit can go to federal tax alone.

Hold longer than a year and the shares qualify for long-term capital gains rates, which are much lower. For 2026:2Internal Revenue Service. Rev Proc 2025-32

  • 0% on taxable income up to $49,450 (single), $98,900 (married filing jointly), or $66,200 (head of household).
  • 15% above those floors up to $545,500 (single), $613,700 (married filing jointly), or $579,600 (head of household).
  • 20% on taxable income above the 15% ceiling.

The gain stacks on top of your other income for the year. That matters when the sale is large. Someone earning $90,000 in salary who realizes $200,000 in long-term gains pays 15% on most of it, but the portion pushing total taxable income above $545,500 gets taxed at 20%. If you are within striking distance of the one-year mark on recently bought shares, waiting even a few weeks can drop your rate from as high as 37% to 15% or 0%.

Your Gain Is the Profit, Not the Sale Price

Tax applies to the difference between what you sell the shares for and your cost basis, which is what you originally paid.3Office of the Law Revision Counsel. 26 USC 1012 – Basis of Property-Cost Buy 500 shares at $40 and sell them at $120, and your taxable gain is $40,000, not the $60,000 in proceeds.

If you bought the same stock over multiple purchases at different prices, each lot has its own basis and holding period. The IRS default is first-in, first-out, meaning your oldest shares are treated as sold first.4Internal Revenue Service. Stocks (Options, Splits, Traders) Those are often the ones with the lowest cost, which produces the largest possible gain.

You can override the default by identifying specific tax lots at the time of sale. Most brokerages let you do this online, and it lets you sell the highest-cost shares first to shrink the taxable gain. The selection has to be made at or before the trade, and your broker has to confirm the specific lots in writing. Dividend reinvestment shares complicate the picture because each reinvested dividend is its own tiny purchase with its own basis, so keep those records.

The 3.8% Surtax on High Incomes

Above certain income levels, an additional 3.8% Net Investment Income Tax applies to investment income, including capital gains. It hits the lesser of your net investment income or the amount your modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly).5Office of the Law Revision Counsel. 26 US Code 1411 – Imposition of Tax Those thresholds are set by statute and have never been indexed for inflation.6Internal Revenue Service.

Pair Winners With Losers

Capital losses offset capital gains dollar for dollar in the same tax year.7Office of the Law Revision Counsel. 26 US Code 1211 – Limitation on Capital Losses A $50,000 gain paired with a $15,000 loss becomes a $35,000 net gain. If your losses exceed your gains for the year, you can deduct up to $3,000 of the excess against ordinary income ($1,500 if married filing separately), and anything beyond that carries forward indefinitely.8Office of the Law Revision Counsel. 26 USC 1212 – Capital Loss Carrybacks and Carryovers

If your portfolio has losing positions you were already planning to exit, selling them in the same year as your home-purchase liquidation is one of the cleanest ways to lower the tax bill. Just watch the wash sale rule.

The Wash Sale Trap

Sell a stock at a loss and repurchase the same or a substantially identical security within 30 days on either side of the sale, and the IRS disallows the loss for that year.9Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities The full restricted window runs 61 days. The disallowed loss is added to the basis of the replacement shares, so it is not permanently gone, but it does not offset the gain in the year you actually need it.

Stock Held Inside Retirement Accounts

Selling shares inside a traditional IRA, Roth IRA, or 401(k) does not trigger capital gains tax. The tax event is the withdrawal, and pulling money out before age 59½ usually costs you a 10% early distribution penalty on top of ordinary income tax.

Traditional IRA

There is a narrow first-time homebuyer carve-out: you can withdraw up to $10,000 in your lifetime without the 10% penalty if the funds go toward buying, building, or rebuilding a first home within 120 days.10Office of the Law Revision Counsel. 26 USC 72 – Annuities; Certain Proceeds of Endowment and Life Insurance Contracts You still owe ordinary income tax on the whole withdrawal — only the penalty is waived. “First-time” here means neither you nor your spouse has owned a principal residence in the prior two years. A married couple where both qualify can each pull $10,000, for a combined $20,000.

Roth IRA

You can withdraw your original Roth contributions at any time, tax-free and penalty-free, for any purpose. Earnings are different: up to $10,000 in earnings can come out tax-free and penalty-free for a first-time home purchase if the account has been open at least five years. If it has not, the $10,000 avoids the penalty but is still taxed as ordinary income. The $10,000 lifetime cap is per person.

401(k)

401(k) plans do not offer a first-time homebuyer exception to the early withdrawal penalty. Some plans allow hardship withdrawals or loans, each with its own restrictions and costs.

No 1031 Exchange for Stock

A common question worth answering directly: you cannot roll stock proceeds into a home purchase through a like-kind exchange. Section 1031 is limited to real property held for business or investment use, and securities are not eligible.11Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment A personal residence would not qualify as investment property either. There is no tax-free path from stock to home.

Practical Ways to Lower the Bill

  • Split the sale across tax years. Selling half in December and half in January puts the gain into two separate returns, which can keep you in a lower bracket and may keep you under the NIIT threshold.
  • Pick specific tax lots. Selling your highest-cost shares first produces the smallest gain per dollar raised.
  • Cross the one-year line before you sell. Long-term rates cap at 20%; short-term rates go to 37%.
  • Harvest losses in the same year, respecting the 30-day wash sale window on either side.
  • Increase deductions in the sale year. Charitable contributions and pretax retirement contributions lower adjusted gross income, which can pull you below the NIIT threshold or into a lower capital gains bracket.

The costliest move is panic-selling a big short-term position because a house came on the market. A few weeks of planning routinely saves thousands.

Estimated Taxes and Reporting

Stock sales get reported on Form 8949, with the totals flowing to Schedule D of your Form 1040. Your brokerage will issue a Form 1099-B, but verify the cost basis it reports, especially for older shares or positions transferred in from another firm.12Internal Revenue Service. Instructions for Form 8949 (2025)

A large mid-year gain has no withholding attached to it unless you ask your broker to withhold. If you expect to owe $1,000 or more beyond your regular withholding, you generally need to make estimated tax payments using Form 1040-ES.13Internal Revenue Service. Estimated Tax for Individuals For 2026, the quarterly deadlines are April 15, June 15, September 15, and January 15, 2027.14Internal Revenue Service. Estimated Tax You avoid the underpayment penalty by paying at least 90% of the current year’s tax through withholding and estimates, or 100% of what you owed last year. If your prior-year adjusted gross income was over $150,000, that safe harbor rises to 110% of last year’s tax.15Internal Revenue Service. Underpayment of Estimated Tax by Individuals Penalty Missing an estimated payment means writing a bigger check at filing time, right when closing costs are still fresh.

Don’t Forget State Tax

Most states tax capital gains as ordinary income, and rates run from zero in a handful of states to top rates near 13%. Short-term gains in a high-tax state can face combined federal and state rates above 50%. Timing and lot selection help with federal exposure, but the state gain is realized in the year of sale regardless. Build the state hit into the number before you decide how many shares to sell.