Autonomous finite element analyses (AFE) based on CT scans predict the biomechanical response of femurs during stance and sidewise fall positions. We combine AFE with patient data via a machine learning (ML) algorithm to predict the risk of hip fracture. An opportunistic retrospective clinical study of CT scans is presented, aimed at developing a ML algorithm with AFE for hip fracture risk assessment in type 2 diabetic mellitus (T2DM) and non-T2DM patients. Abdominal/pelvis CT scans of patients who experienced a hip fracture within 2 years after an index CT scan were retrieved from a tertiary medical center database. A control group of patients without a known hip fracture for at least 5 years after an index CT scan was retrieved. Scans belonging to patients with/without T2DM were identified from coded diagnoses. All femurs underwent an AFE under three physiological loads. AFE results, patient's age, weight, and height were input to the ML algorithm (support vector machine [SVM]), trained by 80% of the known fracture outcomes, with cross-validation, and verified by the other 20%. In total, 45% of available abdominal/pelvic CT scans were appropriate for AFE (at least 1/4 of the proximal femur was visible in the scan). The AFE success rate in automatically analyzing CT scans was 91%: 836 femurs we successfully analyzed, and the results were processed by the SVM algorithm. A total of 282 T2DM femurs (118 intact and 164 fractured) and 554 non-T2DM (314 intact and 240 fractured) were identified. Among T2DM patients, the outcome was: Sensitivity 92%, Specificity 88% (cross-validation area under the curve [AUC] 0.92) and for the non-T2DM patients: Sensitivity 83%, Specificity 84% (cross-validation AUC 0.84). Combining AFE data with a ML algorithm provides an unprecedented prediction accuracy for the risk of hip fracture in T2DM and non-T2DM populations. The fully autonomous algorithm can be applied as an opportunistic process for hip fracture risk assessment.