Railways are greatly threatened by geological hazards whose disastrous effects include severe economic losses as well as serious casualties. It is vital to properly account for such geological hazardous impacts during a railway alignment optimization process. However, geological factors are complex, especially in mountainous regions. Besides, economic factors are also crucial in railway alignment design. Therefore, railway alignment optimization can be termed as a cost‐hazard bi‐objective decision‐making process. So far, least‐cost railway alignment optimization has been studied quite thoroughly while the complicated geological hazard factors have received relatively little attention. In this study, a bi‐objective alignment optimization model considering cost and geological hazard is developed. A novel geological railway alignment optimization model is proposed, which includes spatial geological constraints and geological hazard evaluations, after geological railway alignment design criteria are presented and analyzed for three kinds of typical geological hazards: debris flows, landslides, and rockfalls. The geological hazard evaluation includes geological susceptibility and vulnerability assessments. Then, this model is integrated with a previous least‐cost alignment optimization model to construct a cost‐hazard bi‐objective model. The alignment searching processes are also improved to solve the proposed model by integrating geological‐constraints‐handling and bi‐objective alignment optimization approaches. Finally, the effectiveness of the proposed method is verified by applying it to a complicated real‐world case. The results show that the proposed method can produce less expensive and safer solutions than the best alignment designed by experienced human designers while satisfying all required design standards. Moreover, the method's applicability for solving actual problems is further demonstrated through the sensitivity analysis.