To explore the sedimentary environment and the background of the source area of organic-rich shales in the Wufeng-Longmaxi Formations in the northern Sichuan Basin, samples from Well XX1 in the area were subjected to geochemical testing and analysis of organic carbon content, trace elements, and rare earth elements (REEs). The results show that the total content of REE (ΣREE) of the shale in the Wufeng-Longmaxi Formations varied from 183.08 to 234.66 μg/g with an average of 212.59 μg/g, which is significantly higher than the content of the North American shale composite. The fluctuations in the total amount of REEs in the shale of the Wufeng-Longmaxi Formations reflect certain differences in the geochemical conditions of the Upper Ordovician-Lower Silurian shale. The ratios of LREE/HREE, LaN/YbN, LaN/SmN, and GdN/YbN and the distribution of normalized REE patterns indicate that the source supply or sedimentary structural background may have changed during the shale deposition period of the Wufeng Formation, while the shale deposition period of the Longmaxi Formation may be in a relatively stable source supply and sedimentary structural background. There is no significant correlation between δCe and ΣREE, and the obviously negative Eu abnormity and the weak Ce abnormity indicated that the diagenesis had a limited impact on REEs. Geochemical parameters such as values of ∑REE, δEu, δCe, Ceanom, and LaN/YbN indicate that the climate during the Wufeng-Longmaxi Formation shale deposition period was warm and humid, and the shale was deposited mainly in the suboxic-anoxic water environment. The deposition rate was stable and slow, providing good conditions for the production and preservation of organic matter. At the same time, this shows that the water environment of Wufeng Formation is more anoxic and reductive than that of Longmaxi Formation, which is more conducive to the preservation of organic matter. The correlation between ΣREE and the content of Sc, Ti, Cr, Co, Zr, Nb, Th, Hf, Ta, and other elements indicates that the sources of REEs in the shale of Wufeng and Longmaxi Formations in the study area are similar, mainly terrestrial clasts, and some may come from the sea. The REE distribution pattern shows that the shale provenance of the Wufeng-Longmaxi Formations mainly comes from the upper crust. The La/Yb-∑REE diagram shows that the sediment-parent rocks are mainly early sedimentary rocks and these sediment-parent rocks have granite provenance characteristics. Compared to La/Yb, LREE/HREE, LaN/YbN, and other REE characteristic parameters, it is inferred that the tectonic background of the study area is dominated by passive continental margin.