There is a lack of effective means for precise drug delivery of gastrointestinal diseases. Herein we report a novel magnetically controlled drug delivering capsule endoscope (MDCE) to achieve precision drug delivery for gastrointestinal diseases. MDCE integrates a drug delivery system into conventional capsule endoscope. It can carry 0.5 ml of liquid medication, which can be sprayed onto the target area using an electric pump upon detecting lesions by convolutional neural network (CNN)-model. Additionally, with the aid of an external magnet, the operator can adjust the posture and drug delivery direction of the capsule endoscope to enhance the accuracy of drug release. This adjustment process is monitored in real-time through the camera at the front of the capsule endoscope. To validate the clinical efficacy of the MDCE, we established porcine intestinal epithelial injury and bleeding models, and we demonstrated that MDCE could accurately deliver drugs under magnetic control through direct visualization. MDCE could significantly reduce injury area by delivering organoids to porcine injury sites after 7 days compared to the control group (48 mm