Doncaster were in front within the opening minute as keeper Steve Phillips failed to deal with a Jason Price cross and Paul Heffernan's touch left Jonathan Forte with an open goal from six yards.
Four minutes later the Yorkshiremen were 2-0 ahead as Neil Sullivan's long clearance was latched on to by an unmarked Heffernan, who smashed a low, left-foot shot under the exposed Phillips.
The League Two side then started to find their feet and began to push forward looking for a reply, but were unable to break through.
Richard Walker went closest with a couple of headers, but the Bristol side were still two goals behind at the break.
However, four minutes into the second half the Pirates were back in the game as Sammy Igoe was pulled back as he closed in on a low cross from the left and Walker converted the resulting spot-kick.
Just after the hour Paul Trollope's side sensationally made it 2-2 as Lambert found space down the left and when he lofted the ball over the oncoming Sullivan, Igoe was in the right place to fire the ball home at the far post.
Thirteen minutes from time Sullivan rescued Doncaster with an excellent save from Lambert's ferocious 25-yard free-kick and he then tipped over Igoe's follow-up 30-yarder.
Heffernan wasted a chance to snatch victory in the closing seconds of added time at the end of the 90 minutes, meaning extra-time was needed at the Millennium Stadium.
Five minutes into the second period of extra-time, Doncaster skipper Graeme Lee rose highest to meet Sean Thornton's corner from the left and his thumping header proved to be the matchwinner.