The pentagram map was introduced by R. Schwartz in 1992 for convex planar polygons. Recently, V. Ovsienko, R. Schwartz, and S. Tabachnikov proved Liouville integrability of the pentagram map for generic monodromies by providing a Poisson structure and the sufficient number of integrals in involution on the space of twisted polygons. In this paper we prove algebraic-geometric integrability for any monodromy, i.e., for both twisted and closed polygons. For that purpose we show that the pentagram map can be written as a discrete zero-curvature equation with a spectral parameter, study the corresponding spectral curve, and the dynamics on its Jacobian. We also prove that on the symplectic leaves Poisson brackets discovered for twisted polygons coincide with the symplectic structure obtained from Krichever-Phong's universal formula.