A tunable quantum cascade laser (QCL) spectrometer was used to develop methods for detecting and quantifying high explosives (HE) in soil based on multivariate analysis (MVA) and artificial intelligence (AI). For quantification, mixes of 2,4-dinitrotoluene (DNT) of concentrations from 0% to 20% w/w with soil samples were investigated. Three types of soils, bentonite, synthetic soil, and natural soil, were used. A partial least squares (PLS) regression model was generated for predicting DNT concentrations. To increase the selectivity, the model was trained and evaluated using additional analytes as interferences, including other HEs such as pentaerythritol tetranitrate (PETN), trinitrotoluene (TNT), cyclotrimethylenetrinitramine (RDX), and non-explosives such as benzoic acid and ibuprofen. For the detection experiments, mixes of different explosives with soils were used to implement two AI strategies. In the first strategy, the spectra of the samples were compared with spectra of soils stored in a database to identify the most similar soils based on QCL spectroscopy. Next, a preprocessing based on classical least squares (Pre-CLS) was applied to the spectra of soils selected from the database. The parameter obtained based on the sum of the weights of Pre-CLS was used to generate a simple binary discrimination model for distinguishing between contaminated and uncontaminated soils, achieving an accuracy of 0.877. In the second AI strategy, the same parameter was added to a principal component matrix obtained from spectral data of samples and used to generate multi-classification models based on different machine learning algorithms. A random forest model worked best with 0.996 accuracy and allowing to distinguish between soils contaminated with DNT, TNT, or RDX and uncontaminated soils.