In this study, by means of homotopy perturbation method (HPM) an approximate solution of the magnetohydrodynamic (MHD) boundary layer flow is obtained. The main feature of the HPM is that it deforms a difficult problem into a set of problems which are easier to solve. HPM produces analytical expressions for the solution to nonlinear differential equations. The obtained analytic solution is in the form of an infinite power series. In this work, the analytical solution obtained by using only two terms from HPM solution. Comparisons with the exact solution and the solution obtained by the Pade approximants and shooting method show the high accuracy, simplicity and efficiency of this method.