Dinitrogen (N2) fixation to ammonia (NH3) is typically challenging under mild conditions. Now, lithium hydride (LiH) is shown to mediate photodriven N2 fixation under ambient conditions. Under ultraviolet illumination, LiH is photolysed to release H2, leaving electrons residing in surface hydrogen vacancies, which facilitate N2 activation and photocatalytic NH3 synthesis.