Inspired by the shape of water flow in nature, a novel algorithm for global optimization, water flow optimizer (WFO), is proposed. The optimizer simulates the hydraulic phenomena of water particles flowing from highland to lowland through two operators: 1) laminar and 2) turbulent. The mathematical model of the proposed optimizer is first built, and then its implementation is described in detail. Its convergence is strictly proved based on the limit theory. The parametric effect is investigated. The performance of the proposed optimizer is compared with that of the related metaheuristics on an open test suite. The experimental results indicate that the proposed optimizer achieves competitive performance. The proposed optimizer was also successfully applied to solve the spacecraft trajectory optimization problem.