The India side, and the fund contrast
In India, selling listed shares gives a long-term gain, over ₹1.25 lakh, taxed at 12.5% under Section 112A if held more than a year, and a short-term gain at 20% under Section 111A if held less. Unlisted shares are taxed at 12.5% long-term. These are the same rates any NRI faces.
The good news for a US person is what these are not. Indian direct shares, actual company stock, are not passive foreign investment companies, so they escape the punitive US fund regime that makes Indian mutual funds and ELSS so painful and paperwork-heavy for a US taxpayer. Direct shares are ordinary capital assets for the US, taxed like any stock. So if your Indian holdings are direct equity rather than mutual funds, the US side is far simpler.
The US measures the gain differently
The US taxes the whole gain, but on its own rules. Your gain is computed using your US cost basis and US holding period: held more than a year, it is a long-term capital gain at the preferential rates; a year or less, it is taxed as ordinary income. India's ₹1.25 lakh annual exemption and its grandfathering of pre-2018 gains have no US equivalent, so the US taxes from your actual cost with none of those reliefs.
ESOP and RSU shares carry a specific trap. For US tax, your cost basis in shares you received through a plan is their value at vesting, which was already taxed as US wages, not the price you or your employer paid in India. Brokers often report a zero cost by mistake, which would tax the same value twice, so it has to be corrected. And because the US holding period and India's can differ, the same sale can be long-term in one country and short-term in the other, changing the rate on each side.
The credit needs a treaty election
Here is the step most people miss, and it decides whether the India tax is wasted. Normally the US treats a gain on selling stock as arising where the seller lives, so for a US person the gain is US-source. That is a problem, because the foreign tax credit generally needs foreign-source income to sit against, so on the face of it the India tax on the gain is not creditable.
The treaty fixes this, but only if you use it. It contains a re-sourcing rule that lets you elect to treat the gain as Indian-source to the extent India taxed it, which restores the foreign tax credit for the India tax. This election is required and the wording is notoriously awkward, so it is a job for your US preparer, but it must be made, or you pay both the India tax and the full US tax with no relief. A practising CA computes the Indian gain and tax, provides the vesting values and the India-tax-paid detail, and flags the re-sourcing election so your US preparer secures the credit.