The Musketeers had a great chance at the buzzer, when Justin Martin's full-court pass ricocheted off the backboard and straight into the hands of Isaiah Philmore. But Philmore missed the easy layup, the ball bouncing off the rim as he fell to the court in dismay.
Galloway scored 14 points for the 10th-seeded Hawks (18-12, 8-8), who face No. 25 VCU in Friday's quarterfinals at the Barclays Center. The Rams had a bye after finishing second in the regular season.
Travis Taylor led seventh-seeded Xavier (17-14, 9-7) with 16 points and nine rebounds.
The Musketeers had the ball up by a point with 48.8 seconds left but couldn't get a good look after running the clock down. That gave Saint Joseph's possession with 13.2 seconds remaining after the shot clock violation. Galloway drove to the basket and drew the foul on Semaj Christon.
"I knew I could get to the basket," Galloway said.
His free throw routine was "just take my time, relax and shoot the free throw like I had been practicing all week."
The conference tournament offers Saint Joseph's a chance at some redemption after a disappointing season. The preseason pick to win the A-10 after returning their whole roster from a 20-win team, the Hawks instead tied for eighth.
Xaiver, which was one of only eight schools to make at least seven straight NCAA appearances, won't be going back for the eighth time in a row.
"It's almost like a fumble like in football, whoever can come up with it," Xavier coach Chris Mack said of the final play. "We knew we had some guys trailing on the play based on the spacing we put on the floor. It was just an unlucky bounce. It's a tough play, but it wasn't the reason why we lost."
The Musketeers had taken the lead on two free throws by Christon with 67 seconds left. Saint Joseph's turned the ball over on its next possession.
Brad Redford was 4 of 7 on 3-pointers to score 14 points for the Musketeers.
Halil Kanacevic had 11 points, seven rebounds and six assists for Saint Joseph's before fouling out. Leading scorer Carl Jones was 1 for 10 from the floor but made all eight free throw attempts for 11 points.
The Hawks outrebounded Xavier 17-11 in the second half.
Saint Joseph's coach Phil Martelli wanted everyone to know he left a ticket for the new pope.
"He's a Jesuit. It was two Jesuit schools," Martelli said. "I don't know if he was here, but I did leave a ticket for Pope Francis. I wish him well."