We estimate versions of the Nelson-Siegel model of the yield curve of US government bonds using a Markov switching latent variable model that allows for discrete changes in the stochastic process followed by the interest rates. Our modeling approach is motivated by evidence suggesting the existence of breaks in the behavior of the US yield curve that depend, for example, on whether the economy is in a recession or a boom, or on the stance of monetary policy. Our model is parsimonious, relatively easy to estimate and flexible enough to match the changing shapes of the yield curve over time. We also derive the discrete time non-arbitrage restrictions for the Markov switching model. We compare the forecasting performance of these models with that of the standard dynamic Nelson and Siegel model and an extension that allows the decay rate parameter to be time varying. We show that some parametrizations of our model with regime shifts outperform the single-regime Nelson and Siegel model and other standard empirical models of the yield curve.