In this article, a new technique is used to solve the nonlinear boundary value problem of a cantilever-type nanoelectromechanical system. The technique is called the optimal perturbation iteration method and it is used to solve the problem in the form of a nonlinear differential equation with negative power-law nonlinearity. A convergence and error estimation of the proposed method is presented proving that the method is convergent. Results for the application of the proposed technique are demonstrated through two examples and the tables and figures prove that the method is efficient and straightforward.