Aiming at the problems of incomplete prediction results of gas diffusion, low prediction efficiency of gas diffusion, and inaccurate positioning results of gas diffusion source, an emergency prediction algorithm for port flammable and explosive gas leakage and diffusion is proposed. The leakage modes of different leakage sources are analyzed, and the gas leakage velocity is calculated. According to the calculation results, the conservation control equation of gas leakage diffusion process is established, and the detailed description of gas diffusion process is realized; a gas diffusion emergency prediction algorithm based on Gauss plume model is designed, and the constraint conditions of Gauss plume model are given. Through the prediction algorithm, the gas diffusion emergency prediction results are output, and the gas leakage diffusion emergency prediction is completed. The experimental results show that the gas diffusion range obtained by the algorithm is wide, the gas diffusion prediction efficiency can reach up to 75%, and the gas diffusion source positioning accuracy can reach up to 70%, which shows that the method can realize the accurate and rapid prediction of gas diffusion, and has a positive and important role in the study of natural gas diffusion and environmental governance and optimization of port area © 2021, Saudi Society for Geosciences.