From what I hear is nitrates, are reduced to nitrItes then to nitrogen gas. It is also possible the nitrItes are further reduced to ammonia under certain conditions.
All that relies on low oxygen (anoxic) or no oxygen (anaerobic) bacteria.
Another method and much more desirable IMHO is to use algae (macros, turf, corraline) to consume the nitrates and carbon dioxide while returning fish food and oxygen. One plus is that should ammonia be present, the algae will consume that first (then the nitrates) for nitrogen. Which tends to break up dangerous spikes and possible tank crashes.
my .02