Where does Black labor under a pin? On the fifth rank; hence the importance of scanning horizontally as well as vertically and diagonally in search of pieces lined up with each other. It looks like trouble. The f5 bishop is attacked twice (by White’s queen and bishop) and protected once (by Black’s queen); if it moves, White plays QxQ. Black has no safe way to bring more pieces to the bishop’s defense. He needs a different idea. Consider what threats the pieces in the pin can make.
The queen has no threats to make that do not result in its capture. But what about his bishop? It can't give check, but don’t stop there. Ask how Black’s other pieces bear on White’s king, and whether the bishop can be coordinated with them to create a mating threat. Black currently has one bishop that cuts off the White king’s flight squares e1 and d2; and his rook cuts off e2. The king’s position thus is perilous, and Black can make it more so by playing BxB. This adds a second attack on e2, and so threatens Be2# on the next move if White plays QxQ. But if White decides to defend against the mate threat with c2xB, Black is the one who plays QxQ. (Qxd3+ might seem tempting at that point, but then White interposes with Nd2.) So c2xB would be a blunder for White; the correct way out of the situation Black creates with BxB is for White to save his queen first with a check that consumes Black’s reply move and gives White time to fend off the mate threat. Thus in reply to Black’s BxB, White's best play is Qg4+. Black can't carry out his mate threat because he's in check, and he's about to lose his bishop (to c2xB) if he leaves it where it is; his best bet now is to address both issues by using the bishop to block White's check: Bg6 moves the bishop out of danger while extinguishing the threat to his king. When the smoke clears, Black not only has saved the bishop that was pinned at the outset but has won a piece.
Notice the importance of paying attention to how you can create mate threats—not necessarily because you expect to be able to carry them out, but because they allow you to control your opponent’s moves and, in this case, buy time to escape trouble.
Incidentally, Black also has a simpler way out of the pin that is not quite as strong but is worth seeing anyway: Be4. Now the bishop is guarded twice, and it also guards the piece (the queen) that was at the back of the pin.