In this paper, we obtain the exact upper bound on the number of zeros of Abelian integrals for all quadratic polynomial one-forms over closed orbits of generic quadratic Hamiltonian systems having a saddle loop and a cusp point. This result, together with the results by Horozov and Iliev (1994 Proc. Lond. Math. Soc. 69 198–224), by Gavrilov (2001 Invent. Math. 143 449–97), and by Zhang and Li (1993 Res. Rep. 33; Adv. Math. 26 445–60), gives the final answer to the weak Hilbert 16th problem for n = 2.