We prove the affine Pieri rule for the cohomology of the affine flag variety conjectured by Lam, Lapointe, Morse and Shimozono. We study the cap operator on the affine nilHecke ring that is motivated by Kostant and Kumars work on the equivariant cohomology of the affine flag variety. We show that the cap operators for Pieri elements are the same as Pieri operators defined by Berg, Saliola and Serrano. This establishes the affine Pieri rule.