The disclosure relates to quinazoline derivatives of formula (I) that are useful as inhibitors of voltage-gated sodium channels, wherein the variables are as defined in the specification. The disclosure also relates to pharmaceutically acceptable compositions comprising the compounds of formula (I) and methods of using the compositions in the treatment of various disorders.