Objective: To examine the prevalence and patterns of high risk prescribing, defined as potentially inappropriate prescribing of drugs to primary care patients particularly vulnerable to adverse drug events. Design: Cross sectional population database analysis. Setting: General practices in Scotland. Participants: 315 Scottish general practices with 1.76 million registered patients, 139 404 (7.9%) of whom were defined as particularly vulnerable to adverse drug events because of age, comorbidity, or co-prescription. Main outcome measures: How reliably each of 15 indicators - four each for non-steroidal anti-inflammatory drugs, co-prescription with warfarin, and prescribing in heart failure, two for dose instructions for methotrexate, and one for antipsychotic prescribing in dementia - and a composite of all 15 could distinguish practices in terms of their rates of high risk prescribing; and characteristics of patients and practices associated with high risk prescribing in a multilevel model. Results: 19 308 of 139 404 (13.9%, 95% confidence interval 13.7% to 14.0%) patients had received at least one high risk prescription in the past year. This composite indicator was a reasonably reliable measure of practice rates of high risk prescribing (reliability >0.7 for 95.6% of practices, >0.8 for 88.2%). The patient characteristic most strongly associated with high risk prescribing was the number of drugs prescribed (>11 long term prescribed drugs v 0; odds ratio 7.90, 95% confidence interval 7.19 to 8.68). After adjustment for patient characteristics, rates of high risk prescribing varied by fourfold between practices, which was not explained by structural characteristics of the practices. Conclusions: Almost 14% of patients defined as particularly vulnerable to adverse drug events were prescribed one or more high risk drugs. The composite indicator of high risk prescribing used could identify practices as having above average or below average high risk prescribing rates with reasonable confidence. After adjustment, only the number of drugs prescribed long term to patients was strongly associated with high risk prescribing, and considerable unexplained variation existed between practices. High risk prescribing will often be appropriate, but the large variation between practices suggests opportunities for improvement.