IntroductionWeaning patients from mechanical ventilation is crucial in the management of acute respiratory failure (ARF). Spontaneous breathing trials (SBT) are used to assess readiness for extubation, but extubation failure remains a challenge. Diaphragmatic function, measured by electrical activity of the diaphragm (EAdi), may provide insights into weaning outcomes.Materials and methodsThis prospective, observational study included difficult-to-wean patients undergoing invasive mechanical ventilation. EAdi was recorded before, during, and after extubation. Patients were categorized into extubation success and failure groups based on reintubation within 48 h. Statistical analysis assessed EAdi patterns and predictive value.ResultsThirty-one patients were analyzed, with six experiencing extubation failure. Overall, EAdi increased significantly between the phases before the SBT, the SBT and post-extubation period, up to 24 h (p < 0.001). EAdi values were higher in the extubation failure group during SBT (p = 0.01). An EAdi > 30 μV during SBT predicted extubation failure with 92% sensitivity and 67% specificity. Multivariable analysis confirmed EAdi as an independent predictor of extubation failure.ConclusionsIn difficult-to-wean patients, EAdi increases significantly between the phases before the SBT, the SBT and post-extubation period and is significantly higher in patients experiencing extubation failure. An EAdi > 30 μV during SBT may enhance extubation failure prediction compared to conventional parameters. Advanced monitoring of diaphragmatic function could improve weaning outcomes in critical care settings.