The invention relates to substituted pyridine and pyrimidine compounds of Formula (I) and the pharmaceutically acceptable salts, prodrugs, and solvates thereof, wherein R1, R2a, R2b, A1, A2, X, and Z are defined as set forth in the specification. The invention is also directed to the use of compounds of Formula (I) to treat a disorder responsive to the blockade of sodium channels. Compounds of the present invention are especially useful for treating pain.