Arizona guard Alex Barcello (23) drives the baseline past Texas A&M guard Savion Flagg (5) in the first half of their game in the Valley of the Sun Shootout at Talking Stick Resort Arena, Tuesday, December 5, 2017, Phoenix, Ariz.

Kelly Presnell / Arizona Daily Star

PHOENIX — The Arizona Wildcats took a big step toward slipping back into the top 25 polls Tuesday, edging seventh-ranked Texas A&M 67-64 at Talking Stick Resort Arena.

The Wildcats (6-3) took the lead for good with 1:55 left on a 3-pointer from Parker Jackson-Cartwright and hung on during a tense final two minutes, staying ahead when Texas A&M center Tyler Davis was called for traveling with seven seconds left and Duane Wilson missed the first of three free throws he took with two seconds left.

Wilson, who had been fouled by Deandre Ayton just behind the 3-point line, hit the final two free throws but that left UA with a 65-64 lead. Then, after Dylan Smith was fouled immediately upon UA's inbounds, Smith hit both free throws he took with two seconds still on the clock for the final score.

Ayton finished with his seventh double-double in nine games as a college player, with 13 points and 10 rebounds, while three other Wildcats had 13 points: Dusan Ristic, Smith and Brandon Randolph.

For Smith, a transfer from UNC Asheville, it was a season-high scoring effort.

The win moved Arizona to 6-3 while the seventh-ranked Aggies suffered their first loss of the season in eight games. Arizona also beat Texas A&M 67-63 in Houston last season, the first game of the two-year series.

Trailing by two points at halftime, Arizona took leads of no more than four points in the second half and hung on, taking the lead for good when Jackson-Cartwright hit his 3-pointer from the right corner as he fell to give UA a 61-58 lead with 1:55 left.

After the teams each failed to score on their next possessions, Texas A&M’s D.J. Hogg was fouled by Allonzo Trier with 29 seconds left.

Hogg hit both free throws to pull the Aggies within 61-60 and, after Brandon Randolph hit two free throws for Arizona, Tyler Davis hit an eight-foot hook shot to pull Texas A&M back within one with 17 seconds left.

But the Wildcats had two free throws from Randolph with 17 seconds left and Texas A&M missed a chance to tie it up with seven seconds left when center Davis backed into Ayton along the baseline but took too many steps without a dribble and was called for traveling.

Texas A&M took a 55-54 lead into the final four minutes of the game, having received two tough field goals in a row from Davis, who lofted one of them from the side of the backboard as he jumped up from the baseline.

Trailing 41-39 at halftime, the Wildcats stayed within or ahead of the Aggies by a basket through the first 10 minutes of the second half and had a potential momentum-changer at the midway point of the half, when Randolph drove for a layup and appeared to be grabbed around the head by Texas A&M’s J.J. Caldwell as he neared the basket.

Officials ruled it a flagrant foul on Caldwell, and Randolph hit both ensuing free throws to give UA a 47-45 lead, but Caldwell stole the ball when UA took possession after the free throws. Caldwell went on to turn it over himself, but Texas A&M eventually took a 49-47 lead when Hogg hit a 17-footer from the right wing.

Appearing to be displeased with Smith’s defense on that play, UA coach Sean Miller had a few words with him entering a timeout and then Miller threw his clipboard on the floor and broke it.

In the first half, Wilson scored 12 first-half points for Texas A&M, including a 3-pointer with 18 seconds left before halftime, to give the Aggies a 31-29 halftime lead.

Smith scored 11 first-half points off the bench and the Wildcats tightened up their initially shaky defense to make a run at the unbeaten Aggies.

Smith, who hadn't previously scored more than seven points in a game for Arizona, hit 4 of 5 shots in the first half. Ayton added seven points and seven rebounds for UA, which shot 42.9 percent from the field.

Texas A&M shot just 39.4 percent.

Arizona started out poorly, allowing the Aggies to hit their first four shots and take a 9-4 lead that prompted a timeout from Miller after just two minutes and 15 seconds. But the Wildcats came back to take a 17-11 lead after going on a 9-0 run in just 2:17 toward the middle of the half.

Texas A&M tied it back up and then took a 20-17 lead with a 9-0 run of its own and the game stayed close the rest of the half.