Corrosion defects are dreadfully damaging to the stability of pipelines. Using the finite element (FE) simulation method, a model of API 5L X65 steel pipeline is established in this work to study its buckling behavior subjected to axial compressive loading. The local buckling state of the pipe at the ultimate axial compressive capacity was captured. Compared with the global compressive strain capacity (CSCglobal), the local compressive strain capacity (CSClocal) is more conservative. Extensive parametric analysis, including approximately 115 FE cases, was conducted to study the influence of the corrosion defect sizes and internal pressure on the corroded pipe’s compressive loading capacity (CLC) and CSC. Results show that the enlarged size of the corrosion defect decreases both the CLC and the CSC of the pipeline, but the CLC almost keeps unchanged as the length of corrosion defects increases. The CLC decreases with the increase of the length of corrosion defects when the length is less than 1.5 and greater than 0.7. The CSC drops significantly until the length of the corrosion defect reached 1.8. The deeper the corrosion defect, the smaller the CLC and the CSC. An increase in the width of corrosion defects tends to correspond to a decrease in the CLC and the CSC. With the increase of internal pressure, the CSC of the pipe gets greater while the CLC gets smaller. Based on the 115 FE results, a machine learning model based on support vector regression theory was developed to predict the pipe’s CSC. The regression coefficient between SVR predicted value and FEM actual value is 98.87%, which proves that the SVR model can predict the CSC with high accuracy and efficiency.