Lyme disease surveillance based on provider and laboratory reports underestimates incidence. We developed an algorithm for automating surveillance using electronic health record data. We identified potential Lyme disease markers in electronic health record data (laboratory tests, diagnosis codes, prescriptions) from January 2017-December 2018 in 2 large practice groups in Massachusetts, USA. We calculated their sensitivities and positive predictive values (PPV), alone and in combination, relative to medical record review. Sensitivities ranged from 57% (95% CI 47%-69%) for immunoassays to 87% (95% CI 70%-100%) for diagnosis codes. PPVs ranged from 53% (95% CI 43%-61%) for diagnosis codes to 58% (95% CI 50%-66%) for immunoassays. The combination of a diagnosis code and antibiotics within 14 days or a positive Western blot had a sensitivity of 100% (95% CI 86%-100%) and PPV of 82% (95% CI 75%-89%). This algorithm could make Lyme disease surveillance more efficient and consistent.