Nikica Jelavic scored twice and Madjid Bougherra and Steven Naismith helped themselves to a goal apiece as the holders cruised into the next round despite Callum Woods and Joe Cardle both netting for the Pars.
Incredibly, Rangers managed the rout without the help of top goalscorer Kenny Miller, who was named on the bench after taking his tally to eight goals in five SPL outings at the weekend.
Neil Alexander replaced Allan McGregor in goal, while Andy Webster also made his first appearance of the season after recovering from injury. It was the defender’s first competitive match for Rangers since a win over the now defunct Gretna in the Clydesdale Bank Premier League more than three years ago.
Dunfermline looked lively early on, but it was Rangers who could have been ahead when Steven Davis exchanged a one-two with Jelavic only to see his close-range effort blocked at the near post by goalkeeper Chris Smith.
Two goals in two minutes put the home side firmly in the driving seat. The opener came courtesy of a cross from the left from Kirk Broadfoot and Jelavic connected well to stab over the line from a few yards out after 21 minutes.
Lafferty then galloped into the box and held off the challenge of a couple of Dunfermline defenders before slotting into the bottom corner to double the advantage.
Bougherra added his name to the scoresheet with 38 minutes gone. Vladimir Weiss displayed some impressive play out on the right flank before delivering a low cross to the feet of the defender who gratefully collected and lashed home.
Just when it appeared the holders were cruising towards victory, the Pars pulled a goal back four minutes before the interval. Willie Gibson’s corner was met by Woods who sent a firm header past Alexander despite the efforts of Broadfoot to clear off the line.
Rangers were left reeling when Dunfermline netted again within a minute of the restart. Gibson was again the provider, this time with a cross from the right for Cardle to leave the net bulging with a powerful header.
But the home side quickly regained their composure and Lafferty claimed his second goal after 47 minutes when he met a Naismith pass before sidefooting past Smith after finding himself one on one with the goalkeeper.
Not to be outdone, Jelavic claimed a double of his own in style with an hour gone. He met a ball from Little with his back to goal but managed to find the target with a lovely acrobatic overhead kick that left Smith with no chance.
Lafferty was desperate for his hat-trick and was rewarded for his efforts after 72 minutes with a smart low shot into the bottom corner from 10 yards – and there was still more to come from Rangers.
Naismith completed the rout five minutes later, meeting a curling cross from Broadfoot and rising unchallenged to send a looping header into the back of the net.