This work proposes a rigorous and practical algorithm for quad-mesh generation based the Abel–Jacobi theory of algebraic curves. We prove sufficient and necessary conditions for a flat metric with cone singularities to be compatible with a quad-mesh, in terms of the deck-transformation, then develop an algorithm based on the theorem. The algorithm has two stages: first, a meromorphic quartic differential is generated to induce a T-mesh; second, the edge lengths of the T-mesh are adjusted by solving a linear system to satisfy the deck transformation condition, which produces a quad-mesh.In the first stage, the algorithm pipeline can be summarized as follows: calculate the homology group; compute the holomorphic differential group; construct the period matrix of the surface and Jacobi variety; calculate the Abel–Jacobi map for a given divisor; optimize the divisor to satisfy the Abel–Jacobi condition by integer programming; compute a flat Riemannian metric with cone singularities at the divisor by Ricci flow; isometrically immerse the surface punctured at the divisor onto the complex plane and pull back the canonical holomorphic differential to the surface to obtain the meromorphic quartic differential; construct a motorcycle graph to generate a T-Mesh.In the second stage, the deck transformation constraints are formulated as a linear equation system of the edge lengths of the T-mesh. The solution provides a flat metric with integral deck transformations, which leads to the final quad-mesh.The proposed method is rigorous and practical. The T-mesh and quad-mesh results can be applied for constructing Splines directly. The efficiency and efficacy of the proposed algorithm are demonstrated by experimental results on surfaces with complicated topologies and geometries.