Time series of counts are often characterized by high overdispersion and persistence. These extreme features challenge the existing models. We approach this problem by combining the framework of INAR with a latent Markov structure. We call it HMM-INAR since it belongs to the class of hidden Markov models. We study the probabilistic properties of HMM-INAR model and illustrate conditions for the existence of an ergodic and stationary solution. We show that the HMM-INAR model is identifiable and can be estimated by maximum likelihood via an efficient expectation-maximization (EM) algorithm with steps available in closed form. The HMM-INAR well predicts the distributional and dynamic features of the time series of counts under investigation, i.e. the number of monthly bankruptcies in South Korea, and the number of trades and volume of several NYSE stocks observed at high frequency. Finally, the model proves empirically superior to other INAR specifications.