The left-back powered the ball into the top corner amid some early pressure and the home side repelled Motherwell's comeback attempts to end the SPL's only unbeaten away record.
Motherwell had some good possession and midfielder Nicky Law had a header cleared off the line but Hearts were never under the cosh and substitute John Sutton squandered a chance to make the game safe.
Motherwell had not played for three weeks but they showed no signs of initial rustiness as winger Jamie Murphy threatened inside 45 seconds with a run and shot that Jamie MacDonald pushed wide at full stretch. But Hearts quickly forced their way on the front foot and Andrew Driver curled just wide from 20 yards before they took the lead after 14 minutes.
A quick free-kick 10 yards inside the Motherwell half found its way to Grainger, who was allowed to run forward and unleash a powerful 25-yard strike into the top corner.
Motherwell rediscovered their attacking game midway through the half with the catalyst a good piece of skill from Chris Humphrey that took him past Grainger. The winger found Keith Lasley in the box but the Motherwell skipper was off balance as he shot wide.
Hearts were sitting deep but lone striker Callum Paterson managed to get a shot on target from outside the box with Darren Randolph equal to it.
Motherwell suffered a major blow as the 45 minutes elapsed when centre-back Shaun Hutchinson went off with what appeared to be a hamstring injury. Fraser Kerr moved inside and Tom Hateley returned to right-back with Stuart Carswell having to wait until after the interval to come on in midfield.
Hearts brought on Sutton for Arvydas Novikovas with Paterson moving wide, and the former Motherwell striker missed a great chance midway through the half when he headed wide from six yards after Driver had nodded a half-cleared corner back into the goalmouth.
With 15 minutes left, Hearts created a chance when Michael Higdon headed Humphrey's cross into the path of Law but his header was cleared off the line by Andy Webster. But Motherwell could not sustain the pressure and their hopes died when Hearts cleared an injury-time corner after Randolph had joined his team-mates in attack.