Let V be an N-graded, simple, self-contragredient, C2-cofinite vertex operator algebra. We show that if the S-transformation of the character of V is a linear combination of characters of V -modules, then the category C of grading-restricted generalized V -modules is a rigid tensor category. We further show, without any assumption on the character of V but assuming that C is rigid, that C is a factorizable finite ribbon category, that is, a not-necessarily-semisimple modular tensor category. As a consequence, we show that if the Zhu algebra of V is semisimple, then C is semisimple and thus V is rational. The proofs of these theorems use techniques and results from tensor categories together with the method of Moore-Seiberg and Huang for deriving identities of two-point genus-one correlation functions associated to V .We give two main applications. First, we prove the conjecture of Kac-Wakimoto and Arakawa that C2-cofinite affine W -algebras obtained via quantum Drinfeld-Sokolov reduction of admissible-level affine vertex algebras are strongly rational. The proof uses the recent result of Arakawa and van Ekeren that such W -algebras have semisimple (Ramond twisted) Zhu algebras. Second, we use our rigidity results to reduce the "coset rationality problem" to the problem of C2-cofiniteness for the coset. That is, given a vertex operator algebra inclusion U ⊗ V ֒→ A with A, U strongly rational and U , V a pair of mutual commutant subalgebras in A, we show that V is also strongly rational provided it is C2-cofinite. ROBERT MCRAE 6. Applications 61 6.1. Rationality for C 2 -cofinite W -algebras 61 6.2. Rationality for C 2 -cofinite cosets 66 Appendix A. Differential equations 69 Appendix B. The assumption in Theorem 6.4 for odd nilpotent orbits 74 B.1. Classical types 74 B.2. Exceptional types 76 References 82