Cognitive radio is an emerging technology for sensing and dynamic access of spectrum in mobile radio environments. It aims at dynamically allocating unused bandwidth among secondary users without causing harmful interference to the primary users. This approach, which has clear economical benefits, has recently attracted significant research effort. In this paper, we propose a new approach to dynamic spectrum access in which the occupancy state of each frequency band at each time instant is estimated, and available bands are allocated accordingly. Estimation is performed from power spectral density measurements which are assumed to obey a hidden Markov process. The value of the hidden state represents the status of a given frequency band which could be free or occupied. We have trained the system using real spectrum measurements, and tested it on simulated data for which the occupancy state of each frequency band at each time instant is known. We demonstrate the performance of the proposed approach and compare it with a simple energy detector which has previously been proposed for this application.