Cranie, who joined the Terriers in July 2015 following his release by Barnsley, was set to be out of contract at the end of the season.
The 30-year-old has made 50 appearances since signing for Town.
"I am delighted that we have agreed a deal to keep Martin at the club, as he is a very important player in our squad," head coach David Wagner said.
"I have always said that keeping our good players at the club is just as important as bringing new ones in, so I'm very happy."
Meanwhile, Wagner has revealed that on-loan Chelsea forward Kasey Palmer will be out for eight weeks with a hamstring injury.
The 20-year old suffered the injury in the first half of Town's 2-1 win over Leeds on 5 February.
Huddersfield right-back Martin Cranie has signed a new contract to stay with the Championship club until 2018.