In layered lossless dielectrics between two ground planes there exist the complicated waveguide modes as well as the surface waves in the electromagnetic field induced by a horizontal electric dipole. All these modes can be characterized by the rational parts with the real poles of the spectral domain vector and scalar potentials. The accurate extraction of these modes plays an important role in the evaluation of the Green's function in spatial domain. In our previous work [Song and Hong, 2002] a new algorithm based on rational approximation is presented for the extraction of surface waves and waveguide modes of the Green's function for layered isotropic dielectrics. In this paper, we extend the algorithm to the more complex case of layered anisotropic dielectrics; this algorithm can accurately extract all the real poles and their residues simultaneously. Thus we can get all the surface waves and waveguide modes, which can greatly help in the calculation of the spatial domain Green's function. The numerical results demonstrate the accuracy and efficiency of the proposed method.