  Let $V$ be an $\mathbb{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 $\mathcal{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 $\mathcal{C}$ is rigid, that $\mathcal{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 $\mathcal{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
$C_2$-cofiniteness for the coset. That is, given a vertex operator algebra
inclusion $U\otimes V\hookrightarrow 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.
