Earlier Gary Kelly fired the visitors in front after 33 minutes with a quickly taken free-kick which caught Palace keeper Cedric Berthelin stranded at the opposite post, but Julian Gray levelled within two minutes with a superb 20-yard left-foot volley which whistled past a pack of players before settling into the right hand corner.
Then came Gallagher's clanger but anyway the Eagles plugged away and were the better side for long spells.
Palace boss Trevor Francis said: "Today the players gave me more than I could of asked for with their performance - commitment and some great passing skills. It was a performance that we should not of gone out of the cup with.
"As for the disallowed goal, Francis added: "It was a type of decision that could rock you. Once I looked at it, it was two foot over the line.
"Despite the fact you can dominate the game when you are up against a Premiership side, they have a few players like Kewell that can put away a goal like that."