The present study investigates the mechanical behavior of high-pressure pipelines installed through horizontal directional drilling (HDD), a crucial trenchless installation method, under seismic loads. Utilizing the finite element method and artificial viscoelastic boundary conditions, this paper analyzes the stress response of pipelines subjected to seismic loads in two directions. The seismic loads are applied using the response spectrum method, and the pipeline stress is analyzed in time history. A comparison of the stress in pipelines installed through the HDD method and the traditional open-cut method is conducted, and the impact of earthquake magnitude on pipeline stress is evaluated. The results indicate that the pipeline stress is greater when the seismic acceleration acts transversely, with bending deformation being the dominant mode of response. A 9.29% increase in maximum stress is observed for each increment in earthquake magnitude. Furthermore, the stress in pipelines installed through the HDD method is 48% lower than that of pipelines installed using the open-cut method when subjected to transverse seismic loads.