Preconditioned gradient iterations for large and sparse Hermitian generalized eigenvalue problems Ax = λBx, with positive definite B, are efficient methods for computing a few extremal eigenpairs. In this paper we give a unifying framework of preconditioned gradient iterations for definite generalized eigenvalue problems with indefinite B. More precisely, these iterations compute a few eigenvalues closest to the definiteness interval, which can be in the middle of the spectrum, and the corresponding eigenvectors of definite matrix pairs (A, B), that is, pairs having a positive definite linear combination. Sharp convergence theorems for the simplest variants are given. This framework includes an indefinite locally optimal block preconditioned conjugate gradient (LOBPCG) algorithm derived by Kressner, Miloloža Pandur, and Shao [Numer. Algorithms, 66 (2014), pp. 681-703]. We also give a generic algorithm for constructing new "indefinite extensions" of standard (with positive definite B) eigensolvers. Numerical experiments demonstrate the use of our algorithm for solving a product and a hyperbolic quadratic eigenvalue problem. With excellent preconditioners, the indefinite variant of LOBPCG is the most efficient method. Finally, we derive some ideas on how to use our indefinite eigensolver to compute a few eigenvalues around any spectral gap and the corresponding eigenvectors of definite matrix pairs.