We introduce a new infrared diagnostic to separate galaxies on the basis of their dominant infrared emission: stellar or nuclear. The main novelty with respect to existing diagnostics, is the usage of a broad band encompassing at the same time the 9.7micron Silicate absorption feature and one of the adjacent broad PAH (polycyclic aromatic hydrocarbon) features. This provides a robust estimate of the near- to mid-infrared continuum slope and enables a clear distinction among different classes of galaxies up to a redshift z=2.5. The diagnostic can be applied to a wealth of archival data from the ISO, Spitzer, and Akari surveys as well as future JWST surveys. Based on data in the GOODS, Lockman Hole, and North Ecliptic Pole (NEP) fields, we find out that approximately 70% active galactic nuclei detected with X-ray and optical spectroscopy dominate the total mid-infrared emission. Finally, we estimate that AGN contribute less than 30% of the mid-infrared extragalactic integrated emission.