Pipelines are the most economical and sensible way to transport oil and gas. Long-distance oil and gas pipelines consist of many steel pipes or pipe fittings joined by welded girth welds, so girth welds are an essential part of pipelines. Owing to the limitations of welding conditions and the complexity of controlling weld quality in the field, some defects are inevitably present in girth welds and adjacent weld areas. These defects can lead to pipeline safety problems; therefore, it is necessary to perform failure risk assessment of pipeline girth welds. In this study, an artificial neural network model was proposed to predict the failure risk of pipeline girth welds with defects. Firstly, many pipeline girth weld failure cases, pipeline excavation, and inspection data were collected and analyzed to determine the main factors influencing girth weld failure. Secondly, a spatial orthogonal optimization method was used to select training samples for the artificial neural network model to ensure that the training sample set could cover the feature space with a minimum number of samples. Thirdly, a prediction model based on BP neural networks was established to predict the failure risk levels. The training dataset/testing dataset was 602/4215, and the prediction accuracy for all risks of girth welds achieved an acceptable level. This study can provide a valuable reference for pipeline operators to prevent pipeline accidents.