Purpose To evaluate the effect of an intravitreal injection of ranibizumab or bevacizumab for the management and control of diabetic macular edema (DME) with phacoemulsification. Patients and methods The study population included patients with diffuse DME associated with cataract. Preoperative best-corrected visual acuity (BCVA) was determined and recorded in log MAR and then preoperative assessment by fundus fluorescein angiography and optical coherence topography (OCT) was carried out and recorded. The patients were divided into two groups. For the first group, both phacoemulsification with posterior chamber intraocular lens implantation and an intravitreal injection of ranibizumab were performed, group A, and for the second group, both phacoemulsification with posterior chamber intraocular lens implantation and an intravitreal injection of bevacizumab were performed, group B. Four weeks postoperatively, BCVA in log MAR for each patient in each group was determined and recorded; postoperative fundus fluorescein angiography and assessment of the macular thickness with OCT were performed and recorded. Results This study included 30 eyes, 15 in each group; on the basis of the results, in group A, there was an improvement in macular edema and reduction in central macular thickness (CMT) postoperatively as the mean CMT preoperatively was 397.22±45.43 and improved postoperatively to 328.61±21.64. Also, BCVA improved from 0.96±0.11 to 0.49±0.2. In group B, there was an improvement in macular edema and a decrease in CMT postoperatively as the mean preoperative CMT was 401.8±74.54 and decreased postoperatively to 379.08±78.6; also, BCVA improved from 0.95±0.34 to 0.7±0.1. Conclusion From this study, we concluded that OCT should be performed for all diabetic patients who will undergo cataract surgery preoperatively to assess macular thickness and diagnose the presence of DME; also, both ranibizumab and bevacizumab play an important role in controlling DME with cataract surgery, with higher efficacy for ranibizumab than bevacizumab.