Using a large data set on credit default swaps, we perform a joint analysis of the term structure of interest rates, credit spreads, and liquidity premia. We select reference companies that fall into two broad industry sectors and two broad credit rating classes. Within each sector and credit rating class, we divide the companies into two liquidity groups based on the quote updating frequency. We then study how the term structures of credit default risk premia differ across industry sectors, credit rating classes, and liquidity groups. We develop a class of dynamic term structure models that include two benchmark interest-rate factors, two credit risk factors for the high-liquidity groups, and an additional default risk factor and a liquidity risk factor that capture the difference between the two liquidity groups. We link these factors to the instantaneous benchmark interest rate and credit spread via both an affine function and a quadratic function, and compare their relative performance. We estimate the models using a three-step procedure. First, we estimate the interest-rate factor dynamics and the instantaneous interest rate function using the libor and swap rates. Second, we take the interest-rate factors and estimate the default-risk dynamics and the instantaneous credit spread function using the average credit default spreads of the high-liquidity group for each industry sector and credit rating class. Third, we identify an additional credit risk factor and a liquidity risk factor using the credit default swap spreads in the low-liquidity group. At each step, we cast the models into a state-space form and estimate the model parameters using quasi-maximum likelihood method. Estimation shows that the quadratic specifications generate better and more uniform performance across the term structure of interest rates and credit spreads. Furthermore, firms in different industry and credit rating classes have different default risk dynamics. Nevertheless, in all cases, default risks exhibit intricate dynamic interactions with the interest-rate factors. Interest-rate factors both predict the default risk and have a contemporaneous impact on it. Within each industry and credit rating class, the average credit default swap spreads for the high-liquidity group are significantly higher than for the low-liquidity group. Estimation shows that the difference is driven by both default risk and liquidity difference. The low-liquidity group has a lower default arrival rate, and also a much heavier discounting due to low liquidity.