We prove an anticyclotomic Iwasawa main conjecture proposed by Perrin-Riou for Heegner points for semi-stable elliptic curves E over a quadratic imaginary field K satisfying a certain generalized Heegner hypothesis, at an ordinary prime p. It states that the square of the index of the anticyclotomic family of Heegner points in E equals the characteristic ideal of the torsion part of its Bloch–Kato Selmer group (see Theorem 1.3 for precise statement). As a byproduct we also prove the equality in the Greenberg–Iwasawa main conjecture for certain Rankin–Selberg product (Theorem 1.7) under some local conditions, and an improvement of Skinner's result on a converse of Gross–Zagier and Kolyvagin theorem (Corollary 1.11).