Selling a stock at a profit feels straightforward until the tax bill arrives months later, sometimes with charges you never anticipated. A single large gain in a taxable brokerage account can do more than trigger capital gains tax. It can push your modified adjusted gross income past the threshold for the 3.8% Net Investment Income Tax, and that same spike can raise your Medicare Part B and Part D premiums two years down the road.
Those deferred consequences rarely show up in basic capital gains calculators, and they catch investors off guard every filing season.
You may also like: REIT stocks: dividends and exposure to U.S. real estate
When a stock sale triggers the Net Investment Income Tax
The 3.8% NIIT applies to the lesser of your net investment income or the amount by which your modified adjusted gross income exceeds certain thresholds. For single filers, that threshold sits at $200,000; for married couples filing jointly, $250,000. These thresholds are not indexed for inflation, which means more taxpayers cross them each year as wages and investment returns grow.
A concentrated stock position sold in one calendar year is the classic scenario. Suppose your ordinary income leaves you comfortably below $250,000 as a couple. A realized gain of $80,000 on a long-held stock could vault your MAGI past the line, exposing part or all of that gain to an extra 3.8% on top of whatever capital gains rate already applies.
Recommended read: AI stocks: valuations and risks for U.S. investors
The practical takeaway: before executing a large sale, run a projection of your full-year MAGI, not just your expected capital gains bracket. If you’re within striking distance of the NIIT threshold, spreading the sale across two tax years can keep you below it entirely.

Short-term vs. long-term capital gains tax rates
The holding period is the single variable that changes your rate the most. Assets held for one year or less generate short-term capital gains, taxed at your ordinary federal income tax rates, which can reach up to 37%. Hold the same asset for more than one year and the gain qualifies as long-term, taxed at preferential rates of 0%, 15%, or 20% depending on your taxable income.
Short-term gains are especially punishing for active traders who rotate positions frequently. The difference between a 37% ordinary rate and a 15% long-term rate on the same dollar of profit is substantial. For anyone debating whether to sell a winning stock a few weeks before the one-year mark, waiting can be the simplest and most effective tax strategy available.
How cost basis affects what you owe
Your cost basis is generally the purchase price of the shares plus any commissions or fees. When you sell, the IRS calculates your gain (or loss) as the sale price minus that adjusted basis. If you bought shares at different times and prices, your broker typically lets you choose a cost basis method (FIFO, specific identification, or average cost for mutual funds).
- Specific identification lets you pick exactly which shares to sell, targeting the highest-cost lots first to minimize the taxable gain.
- FIFO (first in, first out) sells your oldest shares first, which may produce a larger gain if the stock has appreciated over time.
- Average cost is available for mutual fund shares and simplifies tracking but removes the ability to optimize lot selection.
Choosing the right method before the sale matters because you generally cannot switch retroactively once a trade settles.
Capital losses and the $3,000 deduction limit
Losses offset gains dollar for dollar. If you sold one stock for a $10,000 gain and another for a $6,000 loss in the same year, only $4,000 is taxable. When losses exceed gains, you can deduct up to $3,000 of net capital losses against ordinary income per year ($1,500 if married filing separately). Any excess carries forward indefinitely into future tax years.
This makes year-end loss harvesting a practical lever. Reviewing your portfolio in November or December for positions sitting at a loss lets you realize those losses strategically, offsetting gains taken earlier in the year. The wash-sale rule prohibits repurchasing a substantially identical security within 30 days before or after the sale, so plan replacement positions carefully.
Medicare premium surcharges from a one-time gain
This is the consequence most investors overlook entirely. Medicare’s Income-Related Monthly Adjustment Amount (IRMAA) uses your modified adjusted gross income from two years prior. A large capital gain realized in 2026 can increase your Medicare premiums starting in 2028.
The surcharge applies to both Part B (medical insurance) and Part D (prescription drug coverage). There is no way to avoid IRMAA once the income is reported, though you can appeal if the spike was caused by a qualifying life-changing event such as retirement or divorce. A one-time stock sale generally does not qualify for that appeal.
Planning options include spreading dispositions across multiple years or timing the sale during a year when other income is unusually low (a sabbatical, a gap between jobs, early retirement before Social Security begins). Coordinate the sale year with your overall income timeline, not just the market price of the stock.
Tax-advantaged accounts sidestep these issues
Gains realized inside a traditional IRA, Roth IRA, or 401(k) are not subject to capital gains tax in the year of the sale. In a Roth account, qualified withdrawals are entirely tax-free. In a traditional account, you defer taxes until distribution, at which point proceeds are taxed as ordinary income.
Neither type of account triggers NIIT or IRMAA at the moment of sale. This makes tax-advantaged accounts the natural home for assets you expect to trade frequently or for high-growth positions you plan to hold for decades.
Opportunity Zone gain recognition deadline in 2026
Investors who deferred capital gains into Qualified Opportunity Zone funds may face a recognition event in 2026. The deferred gain retains its original character, meaning a short-term gain deferred into an Opportunity Zone fund remains short-term when eventually recognized. That recognized gain adds to your MAGI for the year, potentially triggering the same NIIT exposure and IRMAA consequences discussed above.
If you hold Opportunity Zone investments, model the full tax impact of the recognition event before December, including NIIT thresholds and projected income for the IRMAA lookback period. Waiting until April to discover these layered costs leaves no room to manage them.
Stock market taxes are rarely just about one rate table. A single sale can ripple across your tax return and into future Medicare costs. Running a full-year income projection before selling, choosing your cost basis method deliberately, and harvesting losses in tandem with gains are operational steps that keep those ripple effects under control.

