McGarry said: "It's exciting times to be at Motherwell and I am delighted to be staying here.
"The manager asked me to sign the extension and, given how I feel about the club and the way I've been playing, I had absolutely no hesitations.
"We had a few bits and pieces to sort out but I am delighted to be a Motherwell player now and for the next few years.
"I've been reasonably happy with my form this year. Certainly up until Christmas I felt both I and the team were playing some really exciting stuff.
"I've missed a fair chunk of the last month or so through illness that really knocked me for six.
"I've fully recovered now though and with this really important run of games coming up, I want to play a part in it and ensure we get the third place I think we deserve."