COLUMBIA — This time, her team was in it at the end, trading baskets with a giant of women’s college basketball. As South Carolina coach Dawn Staley watched from the sideline during the waning minutes of Wednesday night’s game against top-ranked Stanford, the 8,000-plus fans stood and roared, recognizing the moment at hand — the biggest win of Staley’s 13-year coaching career.

Down the sideline sat a more experienced coach, a legend of the sport, presiding over an unquestionably more talented roster. Perhaps one day, Staley will be the 59-year-old Hall of Fame coach that Stanford’s Tara VanDerveer was Wednesday. Staley, 42 and in her fifth season at USC, could be building something special with the Gamecocks. That much was evident as Wednesday’s game ticked away and Staley’s team did not budge.

It led by two points with 2:33 left, then tied the score with 1:14 left. But the 21st-ranked Gamecocks could not finish with the precision these games demand.

They made one of two free throws when both would have tied the game with 22 seconds left. They got the ball right back after fouling, down three, but freshman guard Tiffany Mitchell was whistled for a charge with 10 seconds left — a play that typified USC’s scattershot offensive night and sealed a 53-49 win for Stanford.

This would have been the greatest night in program history, the Gamecocks’ first over a team ranked higher than No. 3. Narrowly missing doesn’t wreck their season. Quite the opposite.

Signs of progress were everywhere for the Gamecocks on Wednesday, yet tempered by their shortcomings. They held Stanford to 40.4 percent shooting. The Cardinal entered shooting 51.8 percent. But USC managed to make just 18 of 63 shots (28.6 percent).

USC sophomore forward and leading scorer Aleighsa Welch, of Goose Creek High, played one of her best games, attacking the matchup with Stanford’s imposing post defenders, including 6-3 Chiney Ogwumike, who rates among the nation’s best players. Welch shot 7 of 10 and scored 17 points, two shy of her career high. But USC got little from its No. 2 scorer, Mitchell, who shot 1 of 13 and scored two points.

Senior guard and team leader Ieasia Walker walked into the postgame press conference with red eyes, presumably from tears, and while the Gamecocks stung from the loss, they understood what the entirety of this evening meant for them.

“It showed the potential of the team,” said Welch. “I feel like now, we can kind of just take this game and set it as a bar of where we need to play, to get to where we want to be.”

USC is offensively challenged, and Staley wants Welch to be a more assertive scorer than she was last season. Wednesday, Staley liked what she saw.

“I knew I had to come in and make my presence be felt,” Welch said. “I think I showed myself that I’m able to do it against the best of the best teams. I felt like I’m a lot more confident of a player now.”

Though Welch scored just four points in the first half, USC trailed 24-19 at halftime. In last season’s NCAA tournament Sweet 16, USC trailed Stanford by six at half and lost 76-60. Hosting a No. 1 team for the fifth time ever Wednesday, USC seemed capable of getting its first win in nine tries against No. 1, considering the Gamecocks shot 8 of 33 in the first half.

Their shooting barely improved after halftime, and Staley was left to wonder what might have been. Still, VanDerveer spoke admiringly afterward about how Staley prepared USC to play so physically on defense, which “forced us to do some new things.”

After the Sweet 16 and a win at Tennessee last season, and then what happened Wednesday, these weighty games are no longer new for USC. And as Staley looks to her program’s future, she no longer needs to wonder how her players will handle the stage.

“I didn’t think we would fear Stanford,” Staley said. “We didn’t shock the world, but I think the nation understands the type of basketball we play.”