James McFadden rounded off a man of the match performance with a goal as Iain Vigurs, Lionel Ainsworth and John Sutton added the other strikes with Callum Paterson netting the consolation for Hearts.
The visitors were undone on 18 minutes when McFadden combined with Vigurs and the latter kept his composure to place the ball beyond Jamie MacDonald.
McFadden (37) was the provider again when he kept the ball in play and delivered a deep cross to the far side of the box for Ainsworth to volley home.
Sutton sealed victory as he pounced on 65 minutes after McFadden was bundled over at the edge of the box and the big striker got his shot away despite the best efforts of Hearts defender Danny Wilson.
Hearts pulled a goal back four minutes later when Paterson climbed above Stephan McManus to power in a header at a corner.
And McFadden completed the scoring with a header from a Motherwell free-kick to keep his side in contention for a second-place finish.
Hearts had looked brighter in the opening exchanges but they could have fallen behind seven minutes before the opening goal when an Ainsworth volley deflected off Scott Robinson, and forced keeper MacDonald to readjust and tip the ball over.
Hearts almost levelled the game on 31 minutes when Ryan Stevenson crashed a free-kick narrowly wide of the target.
Keith Lasley and Jack Leitch both had decent efforts, while Sutton put the ball over an empty goal from inside the six-yard box shortly before he scored.