After Keenan Reynolds found Matt Aiken on a 34-yard touchdown pass with 8:55 remaining to give Navy a 34-31 lead, Rees guided the Fighting Irish (7-2) 76 yards down the field on 11 plays, capped by Folston's 1-yard scoring run with 3:47 left.
Rees completed 12-of-20 passes for 242 yards, two TDs and two interceptions as Notre Dame kept its hopes for an at-large BCS bowl bid alive.
Folston finished with 140 rushing yards on 18 carries and George Atkinson III added 74 yards with a score on seven tries for the Irish.
T.J. Jones led Notre Dame's receiving corps with four grabs for 111 yards, including a 36-yard scoring grab.
Reynolds ran for three touchdowns, gaining 53 yards on 22 carries, and also passed for a score for the Midshipmen (4-4).