Increasing dissipation-free supercurrent has been the primary issue for practical application of superconducting wires. For magnesium diboride, MgB 2 , carbon is known to be the most effective dopant to enhance high-field properties. However, the critical role of carbon remains elusive, and also low-field critical current density has not been improved. Here, we have undertaken malic acid doping of MgB 2 and find that the microscopic origin for the enhancement of high-field properties is due to boron vacancies and associated stacking faults, as observed by high-resolution transmission electron microscopy and electron energy loss spectroscopy. The carbon from the malic acid almost uniformly encapsulates boron, preventing boron agglomeration and reducing porosity, as observed by three-dimensional X-ray tomography. The critical current density either exceeds or matches that of niobium titanium at 4.2 K. Our findings provide atomic-level insights, which could pave the way to further enhancement of the critical current density of MgB 2 up to the theoretical limit.