It stretched Rochdale's unbeaten run to eight games as they enjoyed their first ever meeting with Preston in the FA Cup.
Preston had the first chance when Graham Alexander's 20-yard right-foot shot went just over the bar in the 28th minute.
Pawel Abbott was then sent clear but Rochdale keeper Neil Edwards dived bravely at his feet.
Rochdale opened the scoring in the 38th minute when Paul McKenna fouled Lee McEvilly and it was the youngster who hit a 25-yard free kick into the top left-hand corner of the net.
The visitors deservedly led at the break and Preston were forced to made a double substitution for the second period, withdrawing Eddie Lewis and Erik Skora for Iain Anderson and Lee Cartwright.
It was Anderson who equalised in the 48th minute with a 20-yard free kick that flew into the bottom left-hand corner of the net after Simon Grand had fouled Abbott.
Paul Simpson came on for Clive Platt in the 51st minute and two minutes later the player-managerÂ’s free kick flew into the net to secure a famous win for Dale.