The giver: no capital gain, cost passes on
For the person giving the shares, a genuine gift is tax-free. Under Section 47(iii), a transfer of a capital asset under a gift is not regarded as a transfer for capital-gains purposes, so no capital gain arises in the giver's hands, they are not taxed on the difference between what they paid and the shares' current value.
But the gain is not forgiven, it is passed on with the shares. Under Section 49(1), the person receiving the shares takes the giver's original cost, and they also inherit the giver's holding period, so a long-held investment stays long-term in their hands. So the tax simply waits until the receiver eventually sells, when it is computed from the giver's original cost and date. This is why a gift of shares within a family is a clean way to move a holding without triggering tax at the point of the gift.
The receiver, and the exchange-control rules
The receiver is where the tax can arise. Under Section 56(2)(x), if you receive shares without paying for them and their fair market value is more than ₹50,000, that value is taxed in your hands as income, unless the giver is a relative as the law defines it, a spouse, sibling, parent, child and a few others, in which case it is fully exempt. So a gift of shares between close relatives is tax-free on both sides; a gift from a friend or a distant relation is taxable on the receiver at the shares' value, which for unquoted shares is worked out by a prescribed formula.
The other layer, easy to forget, is exchange control. When a resident gives shares of an Indian company to an NRI, or an NRI gives to a resident, it is not just a tax matter; it must comply with FEMA. Broadly, a resident gifting shares to an NRI is subject to a value limit for the year and a cap as a small percentage of the company, must respect the sector's foreign-investment rules, and generally needs prior RBI approval and reporting. These conditions change, so a cross-border share gift should be checked against the current RBI rules before it is done, not after. A practising CA sets up the gift so the tax is clean on both sides and the exchange-control compliance is in place.