A third-round shock looked possible when powerful striker Uche Ikpeazu put the League Two side ahead on 25 minutes but the visitors, who are fifth in the Championship, rallied with a strong second-half performance.
Northern Ireland international Stuart Dallas headed the equaliser from an Alex Mowatt cross on 56 minutes and Mowatt grabbed the winner, flicking on Pontus Jansson's header on 63 minutes.
In the fourth round, Leeds, who won the competition in 1972, will travel to face the winners of non-league side Sutton United and AFC Wimbledon.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
(Reporting by Neil Robinson, editing by Pritha Sarkar)
