Capital gains tax for foreigners selling US stocks — what actually applies?

Trying to understand capital gains tax for foreigners who hold US brokerage accounts. I'm on an F-1 visa, have been in the US for about two years, and sold some ETF positions this year with a decent gain. My broker sent a 1099-B but someone told me nonresident aliens get taxed differently and maybe I shouldn't even be filing a 1040. I tried reading the IRS instructions but the resident vs. nonresident distinction is confusing me. I passed the substantial presence test this year I think, but I'm not 100% sure. Does the type of gain matter — like long-term vs. short-term? And does it matter if the ETFs are US-domiciled? I've already reported everything on a draft 1040 with Schedule D but now I'm second-guessing whether that's even the right form.

32 comments

The substantial presence test is the first thing to nail down before anything else. If you're a nonresident alien (NRA), capital gains tax for foreigners works very differently than for residents. NRAs generally aren't taxed by the US on capital gains from US securities, short-term or long-term alike — but gains connected to a US trade or business, or gains of an NRA who was in the US 183 days or more during the year, are treated differently. The IRS digital assets and investment income rules for NRAs live in Publication 519, not 550. Your visa type and day count determine which return form you even file.

Raj A.

Author

The day count is what's tripping me up. I entered in August two years ago. I've been counting but the F-1 exempt years complicate it.

F-1 students are exempt individuals for the substantial presence test for 5 calendar years. So your days in F-1 status don't count toward substantial presence at all. That likely makes you a nonresident alien still, which changes your whole return.

Schedule D and Form 1040 are for resident taxpayers. If you're a nonresident alien you'd file Form 1040-NR instead. And if you're a nonresident, the 1099-B your broker sent might not even reflect the right withholding situation. Worth figuring out your residency status before you go any further with that draft.

Raj A.

Author

That's what I was afraid of. My broker just issued the 1099-B like any other account. No withholding was taken out.

Form 1040-NR is the nonresident return. For NRAs, capital gains on US securities are generally not subject to US tax unless the gains are effectively connected with a US trade or business or you were in the US 183 days or more during the year. If the 183-day rule applies, the net gain is taxed at a flat 30% (or lower treaty) rate, whether short-term or long-term. The distinction between long-term and short-term doesn't change this, so look at your day count and ECI status carefully.

I dealt with this last year — NRA status, sold US ETFs, got a 1099-B and had no idea what was taxable. I uploaded my 1099-B and my visa entry records to taxr.ai and it went through each lot, flagged which gains were long-term vs. short-term, and drafted a summary showing which lines would go on Form 1040-NR vs. what might not be reportable at all for NRAs. Saved me from filing a full 1040 by mistake. Really useful before I handed everything to a CPA.

Raj A.

Author

Did it also catch anything about treaty benefits? I've seen mentions of a tax treaty between my home country and the US that might affect this.

It did flag the treaty question and listed what information I'd need to look into, but told me to confirm the specific treaty article with a tax professional. It didn't just give me a final answer on that piece.

Tax treaties can override the default NRA rules, so the country you're a resident of matters a lot. Some treaties exempt NRAs from US tax on capital gains entirely. Others don't. You'd look at the specific treaty article covering capital gains and then claim the benefit on Form 1040-NR using a treaty disclosure statement. Publication 901 covers US tax treaties if you want to look up your country.

Form W-8BEN is what you give the broker to certify NRA status and claim any treaty benefits at the source. If you never filed one, your broker may have treated you like a US person, which explains why they issued a 1099-B instead of withholding under the NRA rules. That's worth sorting out with the broker going forward even if it doesn't fix this year.

Raj A.

Author

I definitely never gave them a W-8BEN. The account was opened before I fully understood the distinction. So that might explain the 1099-B.

Same situation for me the first year. The broker just defaulted to treating me as a US person. Had to sort out the form for the following year.

One thing that's easy to miss: US-domiciled ETFs are treated as US situs assets. That matters for estate tax purposes for NRAs (which is a separate and serious issue), but for capital gains the question is still whether the gain is effectively connected income and how many days you were in the US. Gains on US securities for NRAs sitting outside ECI, short-term or long-term, are generally not subject to US income tax, but if you were present 183 days or more they may be taxed at a flat 30%.

The estate tax point is a real one that most people overlook. NRAs holding US-domiciled ETFs can face a very low estate tax exemption compared to US persons. That's a planning issue, not a return issue, but worth knowing.

Form 8833 is what you use to disclose a treaty-based return position. If you're claiming a treaty exemption on capital gains, it goes with Form 1040-NR. Some people skip it thinking it's optional but the instructions say it's required when you're taking a treaty position that overrides the Code.

Correct. And there can be penalties for failing to disclose under section 6712, so it's not something to skip.

Form 1040-NR has its own Schedule NEC for income not effectively connected with a US business. That's where certain NRA income goes, taxed at a flat rate. I uploaded my draft 1040-NR and supporting documents to Taxr and it compared the Schedule NEC entries against my 1099-B lots and pointed out that two short-term lots I'd left off Schedule NEC probably needed to be there. It listed the specific lines. Helped me catch the gap before I filed.

Raj A.

Author

This is exactly the kind of detail I was missing. I didn't even know Schedule NEC existed.

The holding period rule under Publication 550 is worth knowing: for securities traded on an established market, the holding period starts the day after the trade date you bought and ends on the trade date you sold — not the settlement date. So pull the actual trade dates off your 1099-B, not the settlement dates, when you're classifying lots.

Raj A.

Author

My 1099-B shows both dates. I was using settlement date. I need to go back and recheck the lots near the one-year mark.

Yeah anything close to the one-year line is worth double-checking with trade dates. A lot can flip from long to short term that way.

If you end up being a dual-status alien for the year — resident for part, nonresident for part — the return gets more complicated. If you're a resident at year end you'd file Form 1040 with a Form 1040-NR statement for the nonresident period attached; if you're a nonresident at year end you'd file Form 1040-NR with a Form 1040 statement for the resident period attached. That's a situation where a CPA or enrolled agent who handles international returns is really worth it.

Dual-status returns are genuinely one of the more complex individual return situations. Not a DIY project if you have significant gains in both periods.

IRS Topic 409 at irs.gov covers capital gains and losses generally, and Publication 519 is the main guide for nonresident alien taxation. Those two together give you the framework, but 519 is the one that actually addresses NRA-specific rules including capital gains and effectively connected income.

Raj A.

Author

I had been reading Publication 550 and wondering why the NRA rules weren't there. That explains it.

Worth flagging: if you determine you're a nonresident and you already filed a 1040 by mistake, you'd need to file an amended return using Form 1040-X and attach a corrected Form 1040-NR. That's a real process and can take a while to process, so better to get the residency question settled before you file anything.

Filed the wrong form one year and had to amend. The 1040-X process works but it took months to clear.

Schedule D on Form 1040-NR is used for effectively connected capital gains. If your gains aren't ECI, they go on Schedule NEC instead. Getting the right schedule matters because they're taxed differently and the IRS will catch a misclassification when the return is processed.

FIRPTA is a separate withholding regime for dispositions of US real property interests — it doesn't apply to stock in regular US corporations or ETFs unless the entity is a US real property holding corporation. So for plain ETF sales you don't need to worry about FIRPTA withholding.

Good clarification. Some people see "US property" and assume FIRPTA covers everything. It doesn't apply to ordinary stock or ETF positions.

Bottom line from this thread: check the substantial presence test first (Publication 519 for NRAs), confirm your visa type affects your day count, then decide if you're filing 1040 or 1040-NR. The capital gains tax for foreigners question really hinges on that one determination. If your situation has dual-status complexity or a treaty claim, an enrolled agent with international experience is the right call before you file.