The sixth-seeded Panthers (22-6) appeared to be on the way to an easy win, leading 47-22 with 13:40 to play. Louisville (18-12), which trailed 39-16 after a horrible first half in its first Big East tournament game, started chipping away. A 16-1 run got the lead down to 48-38 and what was left of the sellout crowd at Madison Square Garden was starting to get behind the Cardinals.
Louisville coach Rick Pitino had been through this before. He was the coach at Kentucky when the Wildcats wiped out a 31-point second-half deficit to beat LSU 99-95 on Feb. 15, 1994.
When Gray missed two free throws with 32 seconds left, Taquan Dean hit an NBA-distance 3 to make it 57-54.
Krauser and Antonio Graves each made one free throw to get the lead back to five. A jumper by McGee with .9 seconds left got the deficit to three again, but Ronald Ramon made two free throws for the final margin.
The Panthers will play No. 19 West Virginia (20-9), the third seed, in the quarterfinals on Thursday night.
Gray had 14 points and 13 rebounds for Pittsburgh, which shot 20 percent (4-for-20) in the second half. The Panthers went 14-for-22 from the free-throw line over the final 13 1/2 minutes for their only points.
Dean had 15 points to lead Louisville, while McGee added 14 and Terrence Williams had 11 points and eight rebounds.
Pittsburgh had a 22-2 lead with 9:32 left in the first half. Louisville missed its first 11 shots from the field, committed five turnovers and was outrebounded 12-1 in the opening 10 1/2 minutes.
Pittsburgh, which came in having lost three of four, extended the lead to 28 points twice in the first half, the last time at 37-9 with 2:39 left.
Louisville shot 20.8 percent from the field in the first half (5-for-24), but the Cardinals were able to go 13-for-29 in the second half (44.8 percent).
The Cardinals were coming off an 84-80 loss at Connecticut in the regular season finale. Juan Palacios had a career-high 29 points on 8-for-16 shooting in that game. On Wednesday, he finished with two points on 1-for-8 shooting.