WESTPORT — For the New Canaan girls basketball team, wins have been hard to come by all season. A double-digit defeat to Staples almost three months ago was part of a 0-6 start that put the Rams in an immediate hole.

New Canaan got a chance to show how much it has improved since then, and did so in a dramatic 49-45 road win over Staples on Tuesday in the rematch, spoiling senior night and damaging the Wreckers Class LL playoff hopes in the process.

“This is a great win for us,” New Canaan coach Kim Palmer said. “We’ve had some bumps in the road this season and my kids come every day to practice with smiles on their faces. We’ve had some tough losses this year and this win feels really good.”

Sami Stewart hit two foul shots with 8.7 seconds left to break a 45-45 tie and send the Rams to the win. Staples had a shot to tie the game that bounced off the backboard, and Stewart — who hadn’t scored until 5:32 left in the game — sunk two more with 0.1 left on the clock.

“I really wanted to get those in for my team,” Stewart said. “We worked hard the whole game and I wanted to make those for them; they really deserved it. Coach Palmer has taught me when I go to the line to think I will make it. That’s what I saw in my head.”

New Canaan (4-13) had to overcome a double-digit second half deficit to force the wild final minute. Staples led 37-24 with 2:30 left in the third before the Rams connected on several 3-pointers late in the period. New Canaan scored five points on one trip to the basket after a miss on an and-1 attempt led to a 3-pointer by Campbell Armstrong.

The Wreckers lead was still 42-35 with six minutes left but New Canaan’s defense — led by the six-foot Armstrong and her wingspan causing deflections — got it back into the game. The Rams held Staples off the scoreboard for five minutes used a 10-0 run to retake the lead.

“Her defensive play really got the momentum going for us,” Palmer said. “She had enough, I guess. She was frustrated because she wasn’t getting the shots; I keep preaching that her defense gets her offense and she stepped up had a few great defensive stops.”

Both teams committed several turnovers with opportunities to break the 45-45 tie after Alyssa Perry hit a foul shot with 55.2 seconds left to even the score. Staples appeared to be in the clear in transition with less than 15 seconds left, but the hosts missed the layup and Stewart was fouled on the rebound.

“It always seems like it’s one or two plays that decides a game,” Staples coach Paco Fabian said. “I think we had four turnovers at the end of the game; we just turned and threw the ball. We have to protect the ball. It’s very important and we didn’t protect it at the end of the game.”

Armstrong and Karlie Bucci each scored 15 points for New Canaan, which snapped a six-game skid.

Staples (7-10) was hoping to wrap up a state playoff spot, and will have three more chances beginning Thursday against Darien. Though teams with eight wins automatically qualify for states, a rule change this year allows the top 32 teams from each class to qualify.

Last season the Wreckers honored five seniors - most of whom accounted for the offense last season. Three seniors — Alyssa Perry, Gabby Perry and Talia Hendel — were honored Tuesday.

Staples fell behind 9-2 after the first quarter before steadily outscoring the Rams for the next 12 minutes. Gabby Perry’s layup pushed the Wreckers lead to 12 points in the third.

“We want to get to eight wins just to guarantee ourselves,” Fabian said. “Darien and Wilton are two teams I think we can compete with; either game we can win if we play our best.”

rlacey@bcnnew.com, @ryanlacey11

NEW CANAAN 49, STAPLES 45

NEW CANAAN (4-13, 3-10 FCIAC)

Olivia Hunsinger 2 3-6 9; Samantha Stewart 1 4-4 7; Kylie Murphy 1 0-0 3; Campbell Armstrong 5 2-2 15; Karlie Bucci 6 3-4 15; Elena Aliapoulios 0 0-0 0. Totals: 15 12-16 49.

STAPLES (7-10, 4-9 FCIAC)

Rachel Seideman 0 1-2 1 Olivia Troy 4 2-2 8 Gabby Perry 2 0-0 5 Talia Hendel 2 0-0 4 Alyssa Perry 5 1-3 12 Julia Brower 3 2-3 8 Elle Fair 2 0-0 5. Totals: 18 6-10 45.

NEW CANAAN 9 9 14 17- 49

STAPLES 2 18 17 8 - 45

3-point field goals: NC—Hunsinger 2, Stewart, Murphy, Armstrong 3; S—Fair, G. Perry, A. Perry.