Background: Complications arising from uncontrolled Type 2 Diabetes (T2D) poses a significant burden on individuals' well-being and healthcare resources. Digital interventions may play a key role in mitigating such complications by supporting patients to adequately self-manage their condition. Aim: To assess the impact of DiabeText, a new theory-based, patient-centered, mobile health intervention integrated with electronic health records to send tailored short text messages to support T2D self-management. Design and setting: Pragmatic, phase III, 12-month, two-arm randomized clinical trial with T2D primary care patients in Spain. Method: 742 participants with suboptimal glycemic control (HbA1c>7.5) were randomly allocated to a control (usual care) or intervention (DiabeText) group. The DiabeText group received, in addition to usual care, 165 messages focused on healthy lifestyle and medication adherence. Primary outcome: glycated hemoglobin (HbA1c). Secondary outcomes: medication possession ratio, quality of life (EQ-5D-5L), diabetes self-efficacy (DSES); and self-reported adherence to medication, Mediterranean diet (MEDAS-14), and physical activity (IPAQ). Results: At 12 months follow-up, no statistically significant differences in mean HbA1c were observed between the intervention (7.5 [95%CI 6.7 to 8.2]) and control groups (7.4 [6.7 to 8.3]). In comparison with the control group, the DiabeText group showed significant (p<0.05) improvements in self-reported medication adherence (OR=1.4; 95%CI: 1.0 to 1.9), DSES (Cohen's d=0.4), and EQ5D-5L (Cohen's d=0.2) scores; but not in the rest of secondary outcomes. Conclusion: DiabeText successfully improved quality of life, diabetes self-management, and self-reported medication adherence in primary care patients with T2D. Further research is needed to enhance its effects on physiological outcomes.