The deal includes a prorated raise from $2.1 million to $3 million this season with annual increases of $250,000 over the next five years.
The Wildcats (5-3, 2-3 Southeastern Conference) enter Saturday's game at Missouri having won more games than the past two seasons combined and are a win from bowl eligibility.
Barnhart and said in a release that, "Mark is guiding our program in the direction we all want it to go and we are proud to reward that."
Stoops, in his second year at Kentucky, had received a one-year extension in May.