Stanford almost got more than it could handle Friday night from Arizona, a team it had beaten by 30 in Tucson last month.

The Cardinal women held off the Wildcats 56-54 at Maples Pavilion, thanks to a clutch 3 by Alanna Smith and a near-miss at the buzzer by Arizona’s Aari McDonald.

It was Stanford’s seventh straight win over Arizona and its 33rd in the last 34 meetings between the two schools.

Stanford looked out of sync most of the night and shot just 37 percent from the field.

Stanford had 3s by Lacie Hull and Smith to close Arizona’s lead to 54-53 with two minutes left. McBryde missed a 3 with 36 seconds to go. Smith got the rebounds and then hit her big 3 for a 56-54 lead with 29 seconds to go.

Kiana Williams fouled McDonald, but the Arizona star missed both foul shots with 17 seconds left. Still, the Cats weren’t dead.

Destiny Graham stole the ball, and Arizona called timeout with 10 seconds left. McDonald got off what would have been a game-winning 3 with 1 second left, but the ball rimmed out.

Stanford (22-4, 12-3 Pac-12) had 21 points from Alanna Smith, 15 from Lacie Hull and 10 from DiJonai Carrington.

McDonald, the nation’s third leading scorer with a 24.8-point average, had 20 points. Graham, who attended Eastside College Prep in Palo Alto, added 11 for the Wildcats (17-9, 7-8).

The Wildcats showed their claws in a low-scoring first half. McDonald had 12 points in the half, which ended with the Cardinal up 35-27. The lead was just 13-12 after one quarter.

Stanford made just one of its first 3-point tries before Smith nailed one on her way to a 15-point first half. Kiana Williams sank a triple, and Stanford’s last two baskets of the first half were 3s by Lacie Hull.

Sophomore forward Maya Dodson returned to action for Stanford after missing the last two games and 10 conference games in all with a foot injury.

The Cardinal play their final home game of the regular season against No. 17 Arizona State on Sunday at 1 p.m.

Tom FitzGerald is a San Francisco Chronicle staff writer. Email: tfitzgerald@sfchronicle.com Twitter: @tomgfitzgerald