In many areas of research the measured spectra consist of a collection of “peaks” — the sought-for signals — which sit on top of an unknown background. The subtraction of the background in a spectrum has been the subject of many investigations and different techniques, varying from filtering to fitting polynomial functions, have been developed. These techniques yield results that are not always satisfactory and often even misleading. Based upon the rules of probability theory, we derive a formalism to separate the background from the signal part of a spectrum in a rigorous and self-consistent manner. We compare the results of the probabilistic approach to those obtained by two commonly used methods in an analysis of particle induced x-ray emission spectra.