US non resident capital gains tax — what actually applies when you sell US stocks?

Trying to figure out the US non resident capital gains tax situation for my own filing. I'm a nonresident alien (no green card, no substantial presence met this year) and I sold shares in a US-listed company through my brokerage account. The broker sent a 1099-B but I know nonresidents aren't always taxed the same way residents are. The gain is long-term. I can't tell if I owe anything to the IRS, whether I need to file a 1040-NR, or whether the treaty between my country and the US changes anything. I looked at the IRS digital assets page and Publication 550 but neither one really addresses the nonresident side. Has anyone dealt with this? What determines whether a nonresident owes US capital gains tax on stock sales, and what form actually gets filed?

40 comments

Form 1040-NR is the return for nonresident aliens — that much is clear. The harder question is whether the gain is even taxable. For most nonresidents, capital gains on the sale of US stocks (not real property) are not subject to US tax unless you were present in the US for 183 days or more during the tax year under a specific nonresident rule. That 183-day count is different from the substantial presence test used to determine residency status. If you clear that threshold, the gains are taxed at a flat rate — the instructions for Form 1040-NR have the specifics. If you're under 183 days, the gain is generally not US-taxable.

Kevin V.

Author

This is really helpful. I was definitely under 183 days this year. So the gain on US stock (not real property) is likely not taxable at the federal level for me? I still need to figure out the treaty angle though.

The 183-day rule mentioned above applies specifically to nonresident aliens under IRC section 871. It's separate from FIRPTA, which is a whole different regime that kicks in when you sell US real property interests — real estate, certain REITs, that kind of thing. Shares in a regular US corporation listed on an exchange are not FIRPTA property unless the company qualifies as a US Real Property Holding Corporation, which most ordinary listed companies don't.

Correct on FIRPTA — worth flagging because a lot of people conflate the two. If FIRPTA applied, the buyer would typically withhold 15% at closing, and you'd file to reconcile it. Completely different from exchange-traded stock gains.

Kevin V.

Author

Good to know the FIRPTA line is drawn at real property. My sale was ordinary listed equity, so that shouldn't apply.

Tax treaties complicate this further. Many treaties between the US and other countries give exclusive taxing rights on capital gains from stock sales to the country of residence, meaning the US gives up its right to tax even if the US domestic rule would otherwise apply. You'd need to check the specific treaty for your country. The IRS has treaty texts on their site. If a treaty benefit applies, you generally claim it on Form 1040-NR by attaching a disclosure and citing the treaty article.

Treaty positions on 1040-NR require a statement — I believe it's tied to Form 8833 in some cases. Worth checking the 1040-NR instructions on that.

Kevin V.

Author

My country does have a treaty with the US. I'll need to track down the specific article on capital gains and see if it covers stock sales specifically. Some treaties carve out certain types of gains.

Before filing I gave taxr.ai my 1099-B plus my country's treaty text and had it walk through, line by line, how the gain would be reported on Form 1040-NR given the treaty. It flagged which article applied, whether the 183-day threshold was relevant to my situation, and drafted the treaty disclosure statement I'd attach. Really cut down the research time on a form I'd never filed before. For anyone who hasn't filed a 1040-NR — it has its own Schedule NEC (tax on income not effectively connected with a US trade or business) which is where gains taxable at the flat rate would land, separate from Schedule A on that form.

Kevin V.

Author

The Schedule NEC distinction is something I hadn't caught. So the gain goes on Schedule NEC rather than the main income section if it's not ECI? That makes sense now that I think about it — it's passive investment income, not trade income.

Exactly. ECI — effectively connected income — is taxed at graduated rates like a resident. Non-ECI investment income like most capital gains lands on Schedule NEC at a flat rate, or is exempt under a treaty. The 1040-NR instructions lay out which category each type of income falls into.

Schedule NEC on the 1040-NR is where most passive US-source income goes for nonresidents — dividends, certain interest, and gains that cross the 183-day line. If the gain is exempt (either under domestic law because you're under 183 days, or under a treaty), you typically still want to consider whether to file a 1040-NR at all if you have no other US-source income. Sometimes the broker withholds anyway and you need to file to claim a refund.

Withholding is a real issue. If the broker treated you as a US person and withheld on a 1099-B, filing a 1040-NR might be the only way to recover it, even if the underlying gain isn't taxable.

Kevin V.

Author

My broker did not withhold anything — I had a W-8BEN on file so they treated me as a foreign person. So I may not have a refund angle, but I might still need to consider whether to file just to establish the position.

W-8BEN on file is the right move — it certifies to the broker that you're a nonresident and prevents them from treating you as a US person for withholding. Without it, they'd backup withhold. If it was on file and the gain is not US-taxable under domestic law or a treaty, many nonresidents in this situation don't file a 1040-NR at all since they have no US tax liability. That said, if you have any other US-source income that year, you'd need to file anyway.

The W-8BEN also certifies treaty benefits to the payer. So if your country's treaty specifically exempts the gains, the W-8BEN should reference the treaty article, otherwise the payer might not apply it correctly.

Publication 519 (US Tax Guide for Aliens) is the main IRS publication covering this. It walks through the residency tests, what counts as US-source income, and how capital gains are treated for nonresident aliens. If you haven't looked at it, that's the place to start before the 1040-NR instructions.

Kevin V.

Author

I had not seen Publication 519 specifically — thank you. I was looking at Pub 550 which covers investment income generally but doesn't address the nonresident side. I'll pull 519.

One thing that caught me off guard on 1040-NR was the question about days present in the US. You fill out a days-present schedule to support your nonresident status. If you were on certain visa types some days might be excluded from the count, so the actual count can be lower than calendar days in the US.

Exempt individual categories — certain students, teachers, trainees, diplomats — don't count their US days for substantial presence. Same days-exclusion logic applies when the 183-day capital gains test is being checked.

Right, the exempt individual rules are in Pub 519. It's worth going through those carefully if you spent any time in the US during the year on a qualifying visa.

Form 8833 (Treaty-Based Return Position Disclosure) is worth flagging here. If you're claiming a treaty exemption on 1040-NR, the IRS generally requires 8833 to be attached, disclosing the treaty, the article, and the amount of income affected. I had Taxr read through my 1040-NR draft and my treaty notes — it spotted that I'd forgotten to attach 8833 and had the wrong treaty article cited in my notes. Saved me from filing an incomplete return.

Form 8833 is mandatory for most treaty positions that reduce or eliminate US tax. The penalty for omitting it when it's required can be significant — the instructions spell out the exceptions to when it's not required.

Kevin V.

Author

So to be clear: treaty exemption claimed on 1040-NR → attach Form 8833 citing the treaty article and the income amount. Got it. I need to identify the right article in my country's treaty first.

The ECI distinction matters a lot for rates. If somehow your activity rose to the level of a US trade or business — which almost never happens for a passive investor buying and selling exchange-listed stocks — the gain would be ECI, taxed at graduated rates, and you'd report it differently on the 1040-NR. For a typical nonresident holding a brokerage account, you are not in a US trade or business just from trading stocks.

The trader vs. investor distinction for ECI is genuinely rare for nonresidents with ordinary brokerage accounts. Passive holding of US stocks doesn't make you engaged in a US trade or business in most situations.

Form 1040-NR has to be filed by the same general deadline as a 1040 for nonresidents who have wages subject to withholding. If you have no wages withheld, the deadline shifts — the 1040-NR instructions specify the alternative due date. Extensions are available on Form 4868, the same individual extension form used for a 1040.

The 1040-NR instructions are the right place for deadline specifics. The due date turns on whether you had US wages with withholding, so it differs by situation.

State tax is a separate question entirely. Some states tax nonresident capital gains on US-source investments, some don't, and state treaty conformity is not automatic. If your brokerage account is held with a US custodian in a particular state, that state may assert nexus. This is worth checking with someone familiar with that state's rules.

Kevin V.

Author

Hadn't thought about state taxes at all. My custodian is based in a state with no income tax, so hopefully that simplifies it, but I'll look into whether the state even has standing to tax nonresident investment gains.

If the amount of gain is large and treaty application is uncertain, an enrolled agent or CPA who specializes in international tax (specifically nonresident alien returns) is worth consulting. 1040-NR with treaty positions, 8833, and Schedule NEC is not a standard domestic return and the professional needs to know that area specifically.

Agreed. International tax on nonresident returns is a niche. A general CPA who mostly does domestic returns may not be familiar with 8833, the treaty texts, or the Schedule NEC structure.

Kevin V.

Author

My gain is mid-sized — not trivial but not enormous. I'll start with Pub 519 and the 1040-NR instructions and then decide whether to bring in an international tax EA or CPA before filing.

Nonresident aliens don't run their capital gains through the resident forms the way residents do. A lot of people assume the resident forms carry over. For non-ECI gains on Schedule NEC of the 1040-NR, the reporting is on that schedule directly — you're not running it through Form 8949 to Schedule D. For ECI gains it's different, but as others noted, that's not the typical situation for a passive investor.

This is an important correction to flag. Form 8949 and Schedule D are for residents filing Form 1040. On a 1040-NR, non-ECI capital gains go on Schedule NEC. Don't attach a Form 8949 where it doesn't belong.

Kevin V.

Author

This clears up a lot of confusion I had. I kept looking at Form 8949 instructions and they didn't mention nonresidents at all — now I understand why. Schedule NEC on the 1040-NR is the right place for my situation.

Topic no. 851 on irs.gov covers the basics of nonresident alien filing requirements and links to the relevant publications. It's a decent starting point to confirm whether you're required to file at all before going deep into the treaty and Schedule NEC questions.

Pub 519 chapter 2 covers what income is US-source versus foreign-source, which determines what even goes on a 1040-NR. Worth reading that section before the form instructions.

Pulling this together for the original question: nonresident alien selling exchange-listed US stocks with no FIRPTA involvement, W-8BEN on file, under 183 days in the US — domestic law likely doesn't tax the gain, treaty may add further protection, filing a 1040-NR may or may not be required depending on whether you have other US-source income or want to claim a refund. If you do file and claim a treaty exemption, Form 8833 goes with it.

Kevin V.

Author

Having every step laid out together like that is what I needed. Pub 519, check the treaty article, evaluate whether to file 1040-NR, attach 8833 if claiming a treaty position. I know what to do from here.