We have developed a new prior-based source extraction tool, XID+, to carry out photometry in the Herschel SPIRE maps at the positions of known sources. XID+ is developed using a probabilistic Bayesian framework which provides a natural framework in which to include prior information, and uses the Bayesian inference tool, Stan, to obtain the full posterior probability distribution on flux estimates. In this paper, we discuss the details of XID+ and demonstrate the basic capabilities and performance by running it on simulated SPIRE maps resembling the COSMOS field, and comparing to the current prior-based source extraction tool DESPHOT. We show that not only does XID+ perform better on metrics such as flux accuracy and flux uncertainty accuracy, we illustrate how obtaining the posterior probability distribution can help overcome some of the issues inherent with maximum likelihood based source extraction routines. We run XID+ on the COSMOS SPIRE maps from HerMES, using a 24 $mathrm{mu m}$ catalogue as a prior and show the marginalised SPIRE colour-colour plot and marginalised contribution to the cosmic infrared background at the SPIRE wavelengths. XID+ is a core tool arising from the Herschel Extragalactic Legacy Project (HELP) and we discuss how additional work within HELP providing prior information on fluxes can and will be utilised. The software is available at https://github.com/H-E-L-P/XID_plus. We also provide the data product for COSMOS. We believe this is the first time that the full posterior probability of galaxy photometry has been provided as a data product.