A new algorithm based on hidden Markov models (HMM) to discriminate single trial electroencephalogram (EEG) between two conditions of finger movement task is proposed. Firstly, multi-channel EEG signals of single trial are filtered in both frequency and spatial domains. The pass bands of the two filters in frequency domain are 0 similar to 3 Rz and 8 similar to 30 Hz respectively, and the spatial filters are designed by the methods of common spatial subspace decomposition (CSSD). Secondly, two independent features are extracted based on HMM. Finally, the movement tasks are classified into two groups by a perceptron with the extracted features as inputs. With a leave-one out training and testing procedure, an average classification accuracy rate of 93.2% is obtained based on the data from five subjects. The proposed method can be used as an EEG-based brain computer interface (BCI) due to its high recognition rate and insensitivity to noise. In addition, it is suitable for either offline or online EEG analysis.