The lack of a rigorous analytical theory for DNA looping has caused many DNA-loop-mediated phenomena to be interpreted using theories describing the related process of DNA cyclization. However, distinctions in the mechanics of DNA looping versus cyclization can have profound quantitative effects on the thermodynamics of loop closure. We have extended a statistical mechanical theory recently developed for DNA cyclization to model DNA looping, taking into account protein flexibility. Notwithstanding the underlying theoretical similarity, we find that the topological constraint of loop closure leads to the coexistence of multiple classes of loops mediated by the same protein structure. These loop topologies are characterized by dramatic differences in twist and writhe; because of the strong coupling of twist and writhe within a loop, DNA looping can exhibit a complex overall helical dependence in terms of amplitude, phase, and deviations from uniform helical periodicity. Moreover, the DNA-length dependence of optimal looping efficiency depends on protein elasticity, protein geometry, and the presence of intrinsic DNA bends. We derive a rigorous theory of loop formation that connects global mechanical and geometric properties of both DNA and protein and demonstrates the importance of protein flexibility in loop-mediated protein-DNA interactions.