Hegarty joins fellow Murray Park youngsters Lewis Macleod, Robbie Crawford and Barrie McKay in committing his long-term future to the Light Blues and the 20-year-old Northern Irishman is determined to prove his worth.
He said: "It's not been nice to see what's happened to the club in the last year.
"I played against Linfield last year and didn't know what was happening after that and came back without a contract and trained away and was willing to play for the club for nothing at the time.
"I'm glad the club have come past that and there is only one way to look now and that's to the bigger, brighter picture.
"I think it says something about me as a person that I'm still here. I want to work hard and I never give up and I won't be one of these people who back down from a challenge.
"It was a hard time for me because I didn't know whether I was coming or going, but I always wanted to come back and give it everything.
"I'm glad things have worked out and I have two years now to make a big step in my career so I have to keep working hard. I need to show that I deserve this deal."
The Hegarty deal is another major boost to boss McCoist as he attempts to rebuild his depleted squad and lead the Gers back to the Scottish Premier League.
Discussions have also taken placed with Fraser Aird and Kal Naismith about extending their stay at Ibrox and McCoist is confident the future is bright for the Light Blues colts.
"All the boys deserve a lot of credit for coming through and doing their best to make an impact on the team," he told Rangers official website.
"Chris has been one of those lads who has come in and been really solid and we can see just how much it means to him to pull on that blue jersey.
"These lads deserve the reward for their efforts and hopefully they'll be the future of the club for years to come."