Electrocatalytic nitrogen reduction reaction (NRR) is an environmentally friendly method for sustainable ammonia synthesis under ambient conditions. Searching for efficient NRR electrocatalysts with high activity and selectivity is currently urgent but remains great challenge. Herein, we systematically investigate the NRR catalytic activities of single and double transition metal atoms (TM = Fe, Co, Ni and Mo) anchored on g-C6N6 monolayers by performing first-principles calculation. Based on the stability, activity, and selectivity analysis, Mo2@g-C6N6 monolayer is screened out as the most promising candidate for NRR. Further exploration of the reaction mechanism demonstrates that the Mo dimer anchored on g-C6N6 can sufficiently activate and efficiently reduce the inert nitrogen molecule to ammonia through a preferred distal pathway with a particularly low limiting potential of -0.06 V. In addition, we find that Mo2@g-C6N6 has excellent NRR selectivity over the competing hydrogen evolution reaction, with the Faradaic efficiency being 100%. Our work not only predicts a kind of ideal NRR electrocatalyst but also encouraging more experimental and theoretical efforts to develop novel double-atom catalysts (DACs) for NRR.