You are taxed only at sale, not when the shares are purchased. However, the rules for ESPP taxation are more confusing than those for stock options and restricted stock.
In general, participants in a Section 423 ESPP (which offers tax advantages) recognize ordinary income for some or all of the purchase-price discount (e.g. up to 15% of the market price) and recognize a capital gain or loss as the difference between their basis in the stock and the proceeds from the sale of the shares. Your specific tax consequences depend on whether you do or do not meet the holding-period requirements of Section 423 ESPPs, and how the stock price changes between the purchase and your eventual sale.
Example: Your company uses a 15% discount on the value of the stock on the first or last day of the offering period, whichever is lower. The stock price is:
- $10 on the first day of the offering period
- $18 on the last day of the offering period (your purchase date)
- $24 when you sell
You sell the stock after meeting the ESPP holding-period requirement (two years from grant, one year from purchase).
- You recognize ordinary income of $1.50 per share (15% of $10).
- Your tax basis is $10 (ordinary income of $1.50 plus your purchase price of $8.50).
- Your long-term capital gain at sale is $14 per share ($24 minus $10 tax basis).
For your tax return, you will need Form W-2 (whether you met or did not meet the holding periods) and Form 3922 from your company. For the details of ESPP tax-return reporting, including annotated examples of Form 8949 and Schedule D, see the Tax Center.