A product of the Glasgow academy, Gray, 23, has already made 79 appearances for the club since making his debut in 2012 and will remain at Scotstoun until May 2020.
In addition to establishing himself as a key member for the PRO14 outfit, Gray has made his mark in the Scotland national side. Since making his international bow in 2013, the second-rower has earned 38 caps for Gregor Townsend's side, playing a central role in the victory over Australia during November's autumn Tests.
"This club is very special to me. It's where I'm from, my family and my friends are here and it's a city and a club that I love and I care about a lot," Gray told Warriors TV. "I'm very happy to be here and I'm proud to represent this city.
"With the new coaches coming in it has been a very exciting time. Glasgow are a really ambitious club and have been for a few years and I'm delighted to be a part of it."
He continued: "There are huge benefits of staying in Scotland and I really appreciate the support from Scottish Rugby in helping me stay with the Warriors for another two years."
"It's massive for us," added Glasgow head coach Dave Rennie. "He's a phenomenal player with a massive work ethic and the boys love him, so we're rapt he's going to be here for two more years at least."
Gray's new deal is the latest boost for Rennie ahead of Saturday's clash with Edinburgh Rugby, after the club announced Monday that winger Niko Matawalu would be staying in Glasgow until 2019.