STOCKTON – St. Mary’s needed a miracle to keep its season alive.

And the Rams’ prayers were answered.

Noah May scrambled to buy time and found Joe Fontes on a 46-yard touchdown with 16 seconds remaining and St. Mary’s pulled off a thrilling 30-29 victory over Elk Grove-Sheldon in the quarterfinals of the Sac-Joaquin Section Division I playoffs.

Rams coach Tony Franks said what proved to be the winning touchdown was totally improvised.

“It was a scramble, he was holding onto the ball,” Franks said. “I was waiting for him to throw it and he did, and we came down with it. It was just a great play.”

The No. 4 Rams (7-5) will play No. 1 Folsom (11-0) in the semifinals next Friday in Folsom.

May’s connection to Fontes didn’t end the game. The final and deciding point came when Eddie Sanchez booted the extra point, which had to travel 35 yards because of a 15-yard unsportsmanlike conduct penalty after the heart-stopping touchdown.

“It was just reactionary, just playing football,” said May, who completed 8 of 11 passes for 169 yards. “I just trusted my teammates in the end. I just know I had to make a play and I made it happen.”

The Rams committed five turnovers, including a muffed punt return that led to a 4-yard touchdown by Tyrell Smith that pulled the Huskies (10-2) within 23-21 with 7:06 remaining. St. Mary’s punted on its next possession and Sheldon marched 53 yards and took the lead on a 25-yard pass from Francisco Salinas to Michael Graves with 54 seconds left. The pair hooked up again on the two-point conversion and the Huskies appeared to be on their way to the semifinals, leading 29-23.

The Rams started their final drive from their own 37 after Donovan Jordan’s kickoff return. May connected with Dumaurier Cotton and Fontes at the Sheldon 46. May took the snap and with time running out, scrambled to his right and waited a moment before he threw the ball to Fontes, who slipped behind the defender and caught the pass in the end zone.

St. Mary’s entered the fourth quarter leading 23-14 thanks to its defense, which held its own to offset five turnovers – four fumbles and the muffed punt. Sheldon’s Dillon Juniel opened the scoring with an 80-yard fumble return. Salinas threw eight consecutive incomplete passes before the touchdown to Graves in the final minute of play. Salinas took several hard hits but bounced back on his feet each time.

Smith rushed for 130 yards and two touchdowns on 28 carries. The Rams’ Will Brown carried 10 times for 71 yards and Jordan scored on runs of 37 and 46 yards.