Dunfermline consolidated third place in the SPL thanks to late strikes from Lee Bullen and Steve Crawford.
Bullen struck with just 15 minutes left to give the home side the lead after they had fallen behind to a Scott Severin goal and Crawford sealed the points with a last-minute goal.
Dunfermline were without keeper Marco Ruitenbeek who suffered a groin injury in training on Saturday and Derek Stillie took his place.
The back-up keeper was called into action after just two minutes when he turned a right-foot shot from Gary Wales past his post.
Chances were few and far between in a disappointing first half but Wales had another opening in the 25th minute after Jean-Louis Valois hared down the left but the striker could not find the target.
Four minutes later, Kevin McKenna was just too high with a header from a Valois corner and, after 31 minutes, Severin had a header on target from another Valois corner but the ball struck his team-mate Andy Kirk on the goal-line.
It was left to Severin to make the breakthrough eight minutes into the second half when he picked up a loose ball in midfield and, with the Dunfermline defence backing off invitingly, he lashed a right-foot shot past Stillie from 25 yards.
Dunfermline equalised in the 65th minute when Barry Nicholson's shot from the edge of the penalty area was deflected over Roddy McKenzie by McKenna as the Canadian defender tried to close down the shot.
Craig Brewster should have put Dunfermline in front three minutes later after McKenzie had pushed out a shot from Nicholson but the striker lost his footing at the vital moment.
Substitute Mark De Vries then wasted a great opening at the other end when he shot straight at Stillie after Valois had put him through.
Bullen then put Dunfermline ahead when he picked up a long throughball and crashed a right-foot shot high into the net.
After Valois had missed in front of goal for Hearts, Crawford sealed the points with an opportunist goal in the last minute