When Foderingham made a mess of dealing with a David Bates pass back in the 10th minute, Alan Forrest, brother of Celtic winger James Forrest, took advantage to slide in and give the League One side the lead
However, all ended well for the Govan club as returning striker Alfredo Morelos levelled on the half-hour mark, with the Ladbrokes Premiership side ruthless after the break.
Jason Cummings struck from close range in the 65th minute before a double from Josh Windass, one either side of Morelos’ second, preceded a last-minute counter from Jamie Murphy, his first in a Rangers shirt since signing on loan from Brighton.
Murty, whose side were drawn at home to Championship side Falkirk in the quarter-final, said: “I’ve got no problem with Wes.
“If we’re going to play out from the back and shift the ball then he’s going to have the ball at his feet. I’m comfortable with that - although I don’t want it happening too often.
“Wes was fine at half-time; these things happen in football - there was no point in shouting or berating him.
IN PICTURES - Notable Scottish Premiership stars on expiring contracts
“He knew he put us in a hard situation but he’s a big guy who takes responsibility. I was confident we had enough to quality on the pitch and bench to get ourselves back into it.
“We made it a little bit more difficult because the goal gave them a lift but it’s about people being accountable and taking ownership of that and he did that.”
Murty was also pleased with the way Morelos responded to his first-half horror miss moments before he scored, when he scooped a Greg Docherty pass over the bar.
He said: “We have always said Alfredo misses chances but you have to be there to miss them and it took a high level of technique to finish like he did because I’d have side footed the hell out of it rather than lash it like he did.
“I would have been properly safe and that’s the measure of a striker as opposed to a defender, he was the optimist and I’m the pessimist. He finished it well and I’m pleased.”
Rangers will go into the Falkirk tie as heavy favourites, as will holders Celtic, who will host Greenock Morton.
Aberdeen were drawn at home to Kilmarnock, while in the other all-Ladbrokes Premiership tie, Hearts travel to Motherwell.