We investigate the determinants of primary market yields on Spanish sovereign debt, focusing in particular on the role of ESM lending. Using an innovative multi-stage model addressing endogenous factors with machine learning, we fi nd that a positive shift in the risk-free yield curve and an increase in the CDS spread raise primary yields uniformly across the maturities on issue. Higher inflation raises medium- to long-term yields, while longer outstanding maturities raise short-term yields and lower long-term yields. Larger holdings by the Banco de Espana lower short-term yields and raise medium-term yields. While ESM loans raise yields across maturities, their impact on issuing costs is minimal. Volatility in primary yields increases with the risk-free yield curve and falls with liquidity for short maturities. Central bank holdings lower volatility for medium-term maturities, while ESM debt relief lowers uncertainty at short maturities.