The term substitution theorem is a vital theorem in mathematical logic that concerns the replacement operation of variables within terms. In this study, we present a comprehensive formalization and verification of the term substitution theorem using the Coq proof assistant. We define the elementary concepts and theorems of first-order logic embedded in Coq, including terms, variables, assignments, and substitutions. Our findings not only offer a method for constructing a suitable nested recursive function for Coq's inductive types but also establish a solid foundation for further investigations and applications in first-order logic. By verifying the term substitution theorem in Coq, we showcase the capabilities of the Coq proof assistant in the machine-checked verification of mathematical proofs and enhance the robustness and dependability of mathematical reasoning across diverse disciplines.