Understanding the origin of organic material on Mars is a major issue in modern planetary science. Recent robotic exploration of Martian sedimentary rocks and laboratory analyses of Martian meteorites have both reported plausible indigenous organic components. However, little is known about their origin, evolution, and preservation. Here we report that 4-billion-year-old (Ga) carbonates in Martian meteorite, Allan Hills 84001, preserve indigenous nitrogen(N)-bearing organics by developing a new technique for high-spatial resolution in situ N-chemical speciation. The organic materials were synthesized locally and/or delivered meteoritically on Mars during Noachian age. The carbonates, alteration minerals from the Martian near-surface aqueous fluid, trapped and kept the organic materials intact over long geological times. This presence of N-bearing compounds requires abiotic or possibly biotic N-fixation and ammonia storage, suggesting that early Mars had a less oxidizing environment than today.