Background Medication safety has long been recognized as a key issue within the broader patient safety agenda. Errors can occur at any step along the way, from prescribing to the ultimate provision of the drug to the patient. Objective To study the nature, frequency and potential causes of medication errors in one Spanish community pharmacy. Methods A study was conducted over a 13-month period. The data included three types of written reports of incidents: prescribing errors, dispensing near-misses, and dispensing errors. Data for medication errors were collected through the internal records of the pharmacy. Results The sample consisted of 42,000 individual prescriptions, in which there were 2,117 medication errors consisting of 1,127 prescribing errors, 216 dispensing errors, and 774 dispensing near-misses. On the basis of the number of prescriptions handled during the study period, we calculated an error rate of 5.0 % (95 % confidence interval 4.8–5.2 %). The most common cause was illegible prescription (26.2 %). Conclusion This study has shown the incidence of medication errors in the health system and the possibility of detecting them in the community pharmacy. Most of the errors that occurred were reported in the prescribing stage; dispensing errors were reported less frequently.