Strain gradient plasticity theories are being widely used for fracture assessment, as they provide a richer description of crack tip fields by incorporating the influence of geometrically necessary dislocations. Characterizing the behavior at the small scales involved in crack tip deformation requires, however, the use of a very refined mesh within microns to the crack. In this work a novel and efficient gradient-enhanced numerical framework is developed by means of the extended finite element method (X-FEM). A mechanism-based gradient plasticity model is employed and the approximation of the displacement field is enriched with the stress singularity of the gradient-dominated solution. Results reveal that the proposed numerical methodology largely outperforms the standard finite element approach. The present work could have important implications on the use of microstructurally-motivated models in large scale applications. The non-linear X-FEM code developed in MATLAB can be downloaded from www.empaneda.com/codes.