Early detection and defibrillation of ventricular fibrillation (VF) has been associated with improved survival of out-of-hospital cardiac arrest (OHCA) patients treated with automated external defibrillators (AEDs). This study proposes a method for VF detection using ECGs obtained from OHCA patients. The dataset of the study contained 596 10-s ECG segments, 144 shockable and 452 non-shockable, from 169 OHCA patients. The dataset was split patient-wise into training (60%) and test (40%) sets. Each ECG segment was band-pass filtered (1-30 Hz), waveform features were computed and fed as observations to a Hidden Markov Model (HMM) that assigned each observation to one of the two hidden states, shockable or non-shockable. The number of possible observations was reduced using k-means clustering. The optimization of the method consisted of feature selection and optimization of the number of clusters through a forward greedy wrapping approach using patient-wise 10-fold cross validation in the training set. The performance of the method was computed in terms of sensitivity (SE) and specificity (SP) using the test set. This procedure was repeated 500 times to estimate the distributions of the performance metrics. The method showed a mean (SD) SE and SP of 94.4% (3.8) and 97.8% (1.2), respectively. The method is compliant with the American Heart Association requirements.