A generalized ray-transfer matrix for describing the action of an optical element having an arbitrary wavefront aberration is obtained. In this generalized ray-transfer matrix, the action of the aberrated optical element is represented by the product of radial ray-transfer matrices and tangential ray-transfer matrices. The refraction angle of an incident ray is calculated from the gradient of the wavefront aberration at the point of incidence, and the radial and tangential ray-transfer matrices directly use the gradient as a matrix component. To show the validity of the generalized ray-transfer matrix, intercept heights from a spot diagram are calculated with the generalized ray-transfer matrix and compared with those calculated with commercial ray-tracing software.