The 33-year-old scored a crucial 63 in the second innings of the five-wicket victory over Nottinghamshire on Friday, following a first-innings' duck.
England opener Compton had a two-month break from the game earlier this summer in order to "refresh and recharge".
"I was proud of the way I managed to hold things together," he said.
Chasing 235 to win at Trent Bridge, Compton, batting at number three, helped Middlesex from 0-1 to 146-5 in their second innings before John Simpson and James Franklin put on a match-winning partnership of 89.
"As someone who prides myself on tough situations, I wanted to make sure I was on it," Compton told BBC Radio London.
"I haven't been fully in the moment at times this season. I knew how important it was that we stayed solid.
"I can't say enough for how we are growing as a team. There was a calmness and a confidence with how we went about it."
After returning to cricket in early August, Compton hit 131 in his second game back for Middlesex and says his confidence with the bat has returned.
"I went through a period where I wasn't hitting the ball very well," he said.
"There have been a few technical things which haven't helped.
"I felt I moved well in this game and my head led the process well. I felt like I got into strong positions and confidence comes with it."
Middlesex hold a one-point lead over Yorkshire heading into the last two games, with the two sides meeting at Lord's, starting on 20 September, in the final round of matches.
"I felt a bit of pressure because I wanted to get us over the line against Notts," Compton said.
"The intent was to make sure we found a way to do it, because this is the time.
"You don't get too many opportunities to be a county player playing for the title as this stage of the season. It is a fantastic place to be."
Middlesex batsman Nick Compton says it is "nice to contribute again" after helping the side to a win which kept them top of the County Championship.