The nonlinear static and dynamic buckling (snaking motion) analysis of a rotating drilling string laterally constrained in a horizontal well is presented, through a group of fourth-order nonlinear partial differential equations . The analytical approximate solutions to the static and dynamic buckling are obtained via combining Newton linearization with Harmonic Balance Method, and Galerkin's method, respectively. On the basis of the analytical approximate solutions, static post-buckling deformation, critical dynamic buckling load, and two different kinds of snaking motions (i.e. the pipe moves up and down around its static buckling configuration; the pipe moves from one side of the wellbore to the other side) are investigated. Accuracy of the approximate solutions is verified by comparing with numerical solutions. Theoretical results are useful for practical design applications related to calculation of buckling loads and selection of bottom hole-assembly (BHA) elements and pipe rotational speeds . What's more, the solving procedures of accurate analytical approximate solutions to the snaking motions yield rapid convergence with respect to exact numeric solutions. The present results are valid for small as well as large oscillation amplitudes. By combining Newton linearization with Harmonic Balance Method and Galerkin's method, the analytical approximate solutions are explicitly established for static and dynamic buckling of a horizontal drilling string, respectively. • Nonlinear static and dynamic buckling of drillpipe in a horizontal well is studied. • Analytical approximate solutions are obtained by Improved HB and Galerkin method. • The present solution procedures are brief. • Accuracy of approximate solution is verified by comparing with numerical solution.