This paper presents a global optimization method to generate a tool path for flank milling free-form surfaces with a generic cutter based on approximation using the tool envelope surface. It is an extension of our previous work [Gong Hu, Cao Li-Xin, Liu Jian. Improved positioning of cylindrical cutter for flank milling ruled surfaces. Computer Aided Design 2005; 37:1205–13]. First, given initial tool path or tool axis trajectory surface, the grazing points of the tool envelope surface can be calculated. Second, the errors between the tool envelope surface and the designed surface along the normal direction of the tool envelope surface are calculated. Based on this new definition of error, an optimization model is established to get the global optimized tool axis trajectory surface. In order to simplify the calculation, two variants of this method based on the least square criterion are proposed to solve this model. Since this method is really based on the tool envelope surface, it can reduce the initial machining errors effectively. The proposed method can be used not only for cylindrical cutters and conical cutters, but also for generic cutters with a surface of revolution. In addition to ruled surfaces, it also can be used for machining non-ruled surfaces. Finally, several examples are given to prove its effectiveness and accuracy. The generated tool paths and calculated grazing points for test are available in supplementary files for the readers’ convenience in verifying this work in different CAD/CAM systems.