The maximum likelihood estimation of a Markov-switching regression model based on theHamilton .lter is not valid in the presence of endogenous explanatory variables. However, weshow that there exists an appropriate transformation of the model that allows us to directly employthe Hamilton .lter. The transformed model explicitly allows for a vector of bias correction termsas additional regressors, and the new disturbance term is uncorrelated with all the regressors inthe transformed model. Within this framework, a quasi maximum likelihood estimation procedureis presented. A procedure to test for endogeneity based on the Wald statistic or the likelihoodratio statistic is also presented.