Rangers came from a goal behind and having captain Michael Mols red-carded to win at East End Park.
Fernando Rickson (right) equalised for Rangers
Mols was sent off after receiving two yellow cards after Rangers protested against Gary Dempsey's opener from a quickly-taken free-kick.
But stunning strikes from Fernando Ricksen and Chris Burke put the visitors in front.
Ross McCormack scored from the spot after being felled by Barry Nicholson before another Dempsey free-kick.
Rangers manager Alex McLeish had fielded one of his least experienced line-ups ever, due to injury absentees and fears about the surface.
Teenagers Charlie Adams and McCormack were handed first starts and there were four more rookies waiting on the bench in the shape of Lee Robinson, Gary McKenzie, Bajram Fetai and Bob Davidson.
The Pars were able to name first-choice strike pairing Craig Brewster and Stevie Crawford for the first time in almost a month as they prepare for the Scottish Cup final.
Chris Burke fired wide of the Dunfermline goal from outside the box in the third minute.
The winger then just failed to get enough on an attempted chip over goalkeeper Derek Stillie.
Dunfermline applied some pressure and Dempsey thumped a low drive straight at Allan McGregor in the Rangers goal.
Dempsey was controlling the midfield and set up Crawford only for the Scotland striker to fire across goal and wide from 10 yards.
Dunfermline took the lead after 27 minutes, Dempsey taking a free-kick quickly and curling the ball into the back of the net with McGregor, who had been trying to move his wall, motionless at the other post.
The Rangers players were furious they had not been given enough time to prepare and captain Mols was booked for leading the protests.
Mols, playing his last game for the club, was sent off three minutes later after clattering Dempsey to receive a second yellow card.
Both Ricksen and Stephen Hughes were both warned for further challenges on Dempsey.
Ricksen fired in a 42nd minute equaliser from 20 yards against the run of play with a ferocious drive that gave Derek Stillie no chance.
Burke put Rangers 2-1 up in stoppage time with an eye-catching solo effort that saw him chip Stillie from 25 yards.
Another quick free kick set Crawford clear after the break.
But, after the striker set up Barry Nicholson, McGregor came out to block the midfielder's effort.
Crawford drove high over the bar when he had an excellent opportunity to equalise.
McCormack drove into the box and was pulled down by Nicholson and the young striker drove home the spot kick.
But Dempsey foxed McGregor with another free kick into the far corner and also came close to completing his hat-trick with a late equaliser.
It meant a losing East End farewell for the departing Crawford, Stillie and Lee Bullen.
Dunfermline: Stillie, Bullen, Skerla, Labonte, Byrne, Nicholson, Mason, Dempsey, Derek Young, Crawford, Brewster.
Subs: Scott Y Thomson, Kilgannon, Tod, Clark, Greenhill.
Rangers: McGregor, Hutton, Khizanishvili, Ross, Vanoli, Ricksen, Hughes, Adam, Burke, Mols, McCormack.
Subs: Robinson, Lovenkrands, MacKenzie, Fetai, Davidson.
Referee: A Freeland