Ultra-nanocrystalline diamond (UNCD) films exhibit excellent mechanical properties because of their unique structure, such as small grain size and high grain boundary ratio. The effect of nitrogen atoms in nitrogen-doped UNCD films on their structure and mechanical properties deserves in-depth study. In this study, we focus on the microstructure control of UNCD films and its effect on the mechanical properties. Ultra-nanocrystalline diamond films were prepared using microwave plasma chemical vapor deposition under varying nitrogen flow rates. It was observed that the hardness and elastic modulus of UNCD films initially increased and then decreased with the increase of nitrogen flow rate. The structure of UNCD films was characterized using transmission electron microscopy and the crystal quality was analyzed through Raman spectroscopy. Nitrogen-interstitial atom defects were identified in the photoluminescence spectra. These defects contribute to shorter interatomic bonds and enhance the covalent bonds in the crystalline structure, resulting in an increase in hardness. The sp2/sp3 ratio and effective nitrogen atom concentration in the UNCD film were analyzed by X-ray photoelectron spectroscopy. The results indicate that an increase in the effective nitrogen atom concentration corresponds with a notable reduction in grain size, which is simultaneously accompanied by a rise in the number of grain boundaries. Meanwhile, the increase of sp2 content in the UNCD leads to the increase of grain boundary width and density, resulting in the increase of hardness and elastic modulus. This work provides theoretical basis and experimental guidance for the development of high performance UNCD films through precisely regulating the microstructure.