Method for estimating a quantity of nitrogen oxides, NOx, and/or a quantity of ammonia, NH 3, at the outlet of an NOx trap arranged in an exhaust pipe of an internal combustion engine, said engine being able to operate in - either an operating mode with a lean air-fuel mixture, during which the NOx trap stores nitrogen oxides, NOx, referred to as the lean operating mode; - or a regenerative operating mode with a rich air-fuel mixture, during which the NOx trap is drained, referred to as the rich operating mode; said method being executed by a computer with data acquired by a first set of sensors (C1j) and by a second set of sensors (C1k), said method comprising: - a step of obtaining information about the richness of the air-fuel mixture; - a step of identifying the operating mode of the engine; - a first step of processing the data acquired by the first set of sensors (C1j), referred to as the rich processing step, if the identified operating mode of the engine is the rich operating mode; and - a second step of processing the data acquired by the second set of sensors (C2k), referred to as the lean processing step, if the identified operating mode of the engine is the lean operating mode; - at the end of the rich processing step or of the lean processing step, a step of adjusting the quantity of ammonia, NH 3, so that the quantity of ammonia, NH 3, remains below a predefined limiting threshold, said method being CHARACTERIZED IN THAT the rich processing step comprises: - a step of initializing the rich processing; - a first step of acquiring the concentration of nitrogen oxides, NOx, downstream of the NOx trap; - a first step of monitoring the change over time in the concentration of nitrogen oxides, NOx, which is acquired downstream of the NOx trap; and - depending on the result of said monitoring step, a first step of selecting a distribution ratio (α1, α2, α3) of the concentrations of nitrogen monoxide, NO, of nitrogen dioxide, NO 2, and of ammonia, NH 3, downstream of the NOx trap, from a first set of predefined distribution ratios (α1, α2, α3). - either an operating mode with a lean air-fuel mixture, during which the NOx trap stores nitrogen oxides, NOx, referred to as the lean operating mode; - or a regenerative operating mode with a rich air-fuel mixture, during which the NOx trap is drained, referred to as the rich operating mode; said method being executed by a computer with data acquired by a first set of sensors (C1j) and by a second set of sensors (C1k), said method comprising: - a step of obtaining information about the richness of the air-fuel mixture; - a step of identifying the operating mode of the engine; - a first step of processing the data acquired by the first set of sensors (C1j), referred to as the rich processing step, if the identified operating mode of the engine is the rich operating mode; - a step of obtaining information about the richness of the air-fuel mixture; - a step of identifying the operating mode of the engine; - a first step of processing the data acquired by the first set of sensors (C1j), referred to as the rich processing step, if the identified operating mode of the engine is the rich operating mode; - a second step of processing the data acquired by the second set of sensors (C2k), referred to as the lean processing step, if the identified operating mode of the engine is the lean operating mode; - at the end of the rich processing step or of the lean processing step, a step of adjusting the quantity of ammonia, NH 3, so that the quantity of ammonia, NH 3, remains below a predefined limiting threshold, said method being CHARACTERIZED IN THAT the rich processing step comprises: - a step of initializing the rich processing; - a first step of acquiring the concentration of nitrogen oxides, NOx, downstream of the NOx trap; - a first step of monitoring the change over time in the concentration of nitrogen oxides, NOx, which is acquired downstream of the NOx trap; and - depending on the result of said monitoring step, a first step of selecting a distribution ratio (α1, α2, α3) of the concentrations of nitrogen monoxide, NO, of nitrogen dioxide, NO 2, and of ammonia, NH 3, downstream of the NOx trap, from a first set of predefined distribution ratios (α1, α2, α3). - a step of initializing the rich processing; - a first step of acquiring the concentration of nitrogen oxides, NOx, downstream of the NOx trap; - a first step of monitoring the change over time in the concentration of nitrogen oxides, NOx, which is acquired downstream of the NOx trap; and - depending on the result of said monitoring step, a first step of selecting a distribution ratio (α1, α2, α3) of the concentrations of nitrogen monoxide, NO, of nitrogen dioxide, NO 2, and of ammonia, NH 3, downstream of the NOx trap, from a first set of predefined distribution ratios (α1, α2, α3).