When Riverside senior Jenna Greason batted the ball out of the air and into the cage with 39 seconds remaining in the Virginia Class 5 field hockey semifinals Friday, the Rams’ bench erupted as if the goal had secured a victory, rather than just cut their deficit in half.

Yet after the precious few remaining seconds had ticked off the clock, the Rams walked off the turf with a 2-1 loss to Cox at South County High in Lorton.

Still, the goal — and the Rams’ reaction to it — symbolized how far the program has come. Four years ago, Riverside went 3-13 in its first varsity season. This year, the Rams (20-1) won their second straight regional championship and carried an undefeated record into the state semifinals.

Riverside kept the contest close against Cox (20-1), a Virginia Beach program that on Saturday will play for its 21st state championship when it takes on Mountain View in the final.

“This is by far the hardest team we’ve played all year,” Riverside Coach Amy Oldknow said. “We didn’t play our best game, but of what I’ve seen from [Cox], scoring a goal on them and only having a one-goal differential, that says a lot about our team.

“Did we want to win? Of course we did. But to end our season against a team that is so powerful, I’m okay with that.”

Early on, Cox’s physicality put Riverside’s players on their heels, Oldknow said. The Rams struggled to establish possession in the first half and gave up goals to Cox’s Mia LaRusso and Sadie Cohen.

Riverside’s best scoring chance came when two Cox players received penalties at the same time. The Rams tried to take advantage as junior Gurnoor Dhaliwal dashed up the right sideline and then cut toward the goal, but the Rams could not convert.

In the second half, Riverside regained its footing. The Rams kept the Falcons off the scoreboard and generated more scoring chances.

“I think finally they just got comfortable and they realized they could compete,” Oldknow said of her players. “I could see they were going to do everything and anything to get that ball in the cage.”

Greason, a lacrosse player who joined the field hockey team for her junior and senior seasons, finally broke through for the Rams in the final minute, but it wasn’t enough.

Greason and seven other seniors will graduate this spring, but Riverside is set to return with a solid core and a wealth of experience.

“We’ve improved every year since the start,” Dhaliwal said. “We got to the quarterfinals last year [and] we got to the semifinals this year, so it’s the final next year. We’ll be ready.”