Brazilian defender Marcao gave the Turkish side the lead in the 28th minute with a diving header from a corner.
Pedri scored the equaliser for Barcelona with a fine individual goal, receiving a pass from Ferran Torres and leaving two defenders on the floor with great skill before tucking home from close range.
Pierre Emerick Aubameyang headed against the post before the break and the former Arsenal striker put Barca ahead three minutes into the second half with a close-range header after two magnificent stops by Galatasaray goalkeeper Inaki Pena who is on loan from the Spanish club.
Barca ran down the clock, infuriating the home crowd who started throwing bottles and plastic cups onto the field and the referee stopped the game for a few minutes while the Galatasaray players tried to calm their fans down.
Rangers joined Barca in the last eight despite losing 2-1 at Red Star Belgrade, progressing 3-2 on aggregate.
Mirko Ivanic gave the Serbian side hope by scoring the opener early in the first half, but the Scottish side held on and Ryan Kent equalised after the interval.
El Fardou Ben's goal in stoppage time was too little too late for Red Star.
Braga pulled of a spirited 1-1 draw at Monaco, advancing 3-1 on aggregate after winning the first leg 2-0 in Portugal.
In Germany, Atalanta won 1-0 at Bayer Leverkusen thanks to a late goal from Jeremie Boga and advanced to the quarterfinals 4-2 on aggregate.