Hearts came from behind to see off the Pars and move into the fourth round of the Co-operative Insurance Cup.
Striker Graham Bayne fired the First Division side in front at Tynecastle after 15 minutes.
But Csaba Laszlo's side responded strongly after the break and restored parity through Gary Glen's header.
Hearts dominated from then on and secured victory when Michael Stewart fired home from the spot after David Obua was fouled by Neil McGregor.
Glen had been brought into the side to replace the injured Andrew Driver, and early on Hearts lacked a cutting edge.
Dunfermline had an excellent chance to take the lead but Greg Ross's volley was comfortably saved by Janos Balogh.
The visitors took the lead after quarter of an hour when Bayne ran on to Ross's reverse pass and his shot found its way through Balogh.
Marius Zaliukas headed home Craig Thomson's 35th-minute free-kick but was flagged for offside and the Lithuanian volleyed over moments later.
Hearts equalised when Glen headed home Obua's cross 11 minutes after the break as the hosts began to dominate.
Balogh was alert to the danger when he palmed away substitute Joe Cardle's effort before Hearts scored a controversial winner.
McGregor surrendered possession to Obua but appeared to have recovered the ball with a shoulder charge on the Hearts midfielder.
However, referee Brian Winter pointed to the spot and Stewart sent Greg Fleming the wrong way to send Hearts through.
Hearts manager Csaba Laszlo:
"It was a typical cup game, especially in the first 45 minutes.
"We won the game in the second half and I must pay Dunfermline a compliment for the way they played.
"The referee had a choice to give one penalty out of four, so this is okay.
"We lost a lot of energy in the game against Celtic, but in the second half tonight we showed a much better attitude.
"This wasn't an easy game to win. We had chances to score more goals."
Dunfermline manager Jim McIntyre:
"We played very well in the first half and passed the ball well.
"We set up 4-2-3-1 and we've got two really good footballers in there in Burke and Holmes.
"They started a lot of the play for us. The three in front where there to support Graham Bayne up front, but in the second half we were too deep and they weren't getting up to them.
"Credit to Hearts, they changed their system and stopped our full-backs getting forward as well.
"It didn't look like a penalty for me and I'll need to see it on television."