Borderline personality disorder (BoPD or BPD) is highly prevalent and characterized by reactive moods, impulsivity, behavioral dysregulation, and distorted self-image. Yet the BoPD diagnosis is underutilized and patients with BoPD are frequently misdiagnosed resulting in lost opportunities for appropriate treatment. Automated screening of electronic health records (EHRs) is one potential strategy to help identify possible BoPD patients who are otherwise undiagnosed. We present the development and analytical validation of a BoPD screening algorithm based on routinely collected and structured EHRs. This algorithm integrates rule-based selection and machine learning (ML) in a two-step framework by first selecting potential patients based on the presence of comorbidities and characteristics commonly associated with BoPD, and then predicting whether the patients most likely have BoPD. Leveraging a large-scale US-based de-identified EHR database and our clinical expert’s rating of two random samples of patient EHRs, results show that our screening algorithm has a high consistency with our clinical expert’s ratings, with area under the receiver operating characteristic (AUROC) 0.837 [95% confidence interval (CI) 0.778-0.892], positive predictive value 0.717 (95% CI 0.583-0.836), accuracy 0.820 (95% CI 0.768-0.873), sensitivity 0.541 (95% CI 0.417-0.667) and specificity 0.922 (95% CI 0.880-0.960). Our aim is, to provide an additional resource to facilitate clinical decision making and promote the development of digital medicine.