Let V be an N-graded, simple, self-contragredient, C_2-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 C_2-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 C_2-cofinite.