Context. Extraterrestrial materials, such as meteorites and interplanetary dust particles, provide constraints on the formation and evolution of organic matter in the young solar system. Micrometeorites represent the dominant source of extraterrestrial matter at the Earth's surface, some of them originating from large heliocentric distances. Recent analyses of ultracarbonaceous micrometeorites recovered from Antarctica (UCAMMs) reveal an unusually nitrogen-rich organic matter. Such nitrogen-rich carbonaceous material could be formed in a N 2 -rich environment, at very low temperature, triggered by energetic processes. Aims. Several formation scenarios have been proposed for the formation of the N-rich organic matter observed in UCAMMs. We experimentally evaluate the scenario involving high energy irradiation of icy bodies subsurface orbiting at large heliocentric distances. Methods. The effect of Galactic cosmic ray (GCR) irradiation of ices containing N 2 and CH 4 was studied in the laboratory. The N 2 -CH 4 (90:10 and 98:2) ice mixtures were irradiated at 14 K by 44 MeV Ni 11+ and 160 MeV Ar 15+ swift heavy ion beams. The evolution of the samples was monitored using in-situ Fourier transform infrared spectroscopy. The evolution of the initial ice molecules and new species formed were followed as a function of projectile fluence. After irradiation, the target was annealed to room temperature. The solid residue of the whole process left after ice sublimation was characterized in-situ by infrared spectroscopy, and the elemental composition was measured ex-situ. Results. The infrared bands that appear during irradiation allow us to identify molecules and radicals (HCN, CN − , NH 3 , ...). The infrared spectra of the solid residues measured at room temperature show similarities with that of UCAMMs. The results point towards the efficient production of a poly-HCN-like residue from the irradiation of N 2 -CH 4 rich surfaces of icy bodies. The room temperature residue provides a viable precursor for the N-rich organic matter found in UCAMMs.