Abstract Computer numerical control milling provides greater flexibility and universality for machining complex gears compared to dedicated gear manufacturing. A critical challenge in popularizing the use of five-axis flank milling to spiral bevel gears is to achieve acceptable machining accuracy that ensures the meshing performance of the finished gears. Previous studies, which used approaches such as gear design modification, using multiple tool paths, and end milling, failed to resolve this issue. Thus, this paper proposes a computational scheme to improve the machining accuracy of five-axis flank milling of spiral bevel gears by optimizing the tool path and cutter geometry. The scheme minimizes the geometric deviations between the machined surface and original design using heuristics and optimization algorithms. A simplified tooth contact analysis method was developed to quantitatively evaluate the contact path of the meshing gears. The simulation results of real gears show that the proposed scheme outperforms previous methods in reducing machining errors and further enhance the meshing performance by optimizing the design of form cutters. This work developed an effective approach for flexible and low-cost manufacturing of complex gears.