The win was the first for the USF (15-13, 7-8 WCC) over a ranked team since they beat 24th-ranked Gonzaga on Feb. 18, 2012. The Dons had lost 16 in a row to ranked opponents since then.
Saint Mary's (24-4, 13-2) dropped out of a first-place tie with Gonzaga (14-1) with just three games remaining.
The Gaels had embarrassed USF 79-43 in an earlier meeting in Moraga, Calif. The 43 points represented the season-low for both USF and a Saint Mary's opponent.
Saint Mary's led by as many as 11 points in the rematch, 27-16, on an Evan Fitzner layup with 7:34 remaining in the first half.
But the Dons, who entered the game just 3-3 at home in conference play, closed within 38-35 by halftime, then battled the powerful Gaels on better-than-even terms throughout the second half.
McCarthy's critical hoop came after Saint Mary's star Jock Landale gave the Gaels their final lead of the night at 56-55 with a pair of free throws with 4:43 remaining.
Frankie Ferrari hit two key hoops down the stretch for the Dons, who pulled away in the final seconds with six free throws.
Ferrari had a game-high 20 points to lead the Dons, who had gone 0-4 against ranked opponents this season, losing those games by a total of 73 points.
Ferrari hit seven of his 11 shots and found time for a game-high seven assists.
Jordan Ratinho added 13 points for USF, while reserve Jimbo Lull contributed 10 points and a game-high seven rebounds to the win.
USF outshot Saint Mary's 46.0 percent to 42.9 percent.
Landale had a team-high 19 points for Saint Mary's, which was coming off a 78-65 home loss to Gonzaga on Saturday that had created the tie atop the conference standings.
Fitzner finished with 17 points and Emmett Naar 16 to complement a team-high five assists for the Gaels, who took their first road loss in conference play after seven wins.
The Gaels shot just 4-for-14 from 3-point range.
--Field Level Media
St. Mary's | San Francisco | |
Jock Landale 19 | Scoring | Frankie Ferrari 20 |
Emmett Naar 5 | Assists | Frankie Ferrari 7 |
Calvin Hermanson 6 | Rebounds | Jimbo Lull 7 |
Jock Landale 7 | Free Throws Made | Chase Foster 6 |
Calvin Hermanson 2 | Steals | Frankie Ferrari 1 |
Jordan Hunter 4 | Blocks | Nate Renfro 3 |
Team | Points | FG% | 3PM-3PA | FTM-FTA | Assists | Rebounds | Blocks | Steals | Turnovers |
St. Mary's | 63 | 42.9 | 4-14 | 11-15 | 7 | 29 | 7 | 3 | 9 |
San Francisco | 70 | 46.0 | 6-15 | 18-29 | 17 | 31 | 5 | 2 | 7 |