TEMPE, Ariz. (AP) — It was one of those endings that coaches dream of — or one that can keep them up at night.

Up by six in the waning seconds Thursday night, Arizona State had a chance to put away Southern California for an important Pac-12 win but that's not exactly how it went, although the Sun Devils did eventually come away with the victory, 98-93 in overtime.

"Can you believe what we just witnessed out there?" Arizona State coach Herb Sendek said. "That was incredible. I mean, the shots that those two guards were making, I'm still mesmerized."

Sendek was referring to three 3-pointers USC made in the final 22 seconds of regulation that sent the game to an extra period.

Arizona State led 82-76 with 26.8 seconds left but J.T. Terrell hit back-to-back 3-pointers and Jio Fontan hit an off-balance 3-pointer from 25 feet with 0.4 seconds remaining to force overtime.

The teams were tied at 69 with 4:40 left before Arizona State ran off eight straight points, but they couldn't finish the Trojans in regulation. Sendek praised his team for not letting the desperation shot affect them going into overtime.

"But I was so proud of our guys when they came over after regulation," Sendek said. "Because they gave me confidence. They had great body language, great interaction among themselves and they were ready to go play another five minutes."

Evan Gordon led the Sun Devils with 28 points, playing all 45 minutes, and Jonathan Gilling scored five points in the extra period for Arizona State (15-4, 4-2 Pac-12). Gilling finished with 13 points and 11 rebounds.

The Trojans hit 15 of 28 from beyond the arc. They came into the game averaging just over 15 3-point attempts per game.

"We were trying to contest them as best we could," said Arizona State's Jahii Carson. "They were coming off screens and we had our hands right in their face. We just try to play the best D we can."

He added, "At least we got the W."

Carson had 21 points and eight assists for Arizona State but the Sun Devils needed a last-second stop to hold on.

"We don't give up," Trojans interim coach Bob Cantu said. "We keep fighting to the end no matter how much we are down. We hit some big shots at the end to give us a chance to get into overtime which I proud of. We just have to tighten up things on defense."

USC came into the game allowing 65 points a game but allowed 51 percent shooting from the field and Arizona State had 36 free throws, although the Sun Devils missed 11 of them.

In overtime, with USC down 96-93, Fontan missed a 3-pointer from the top of the key with 5 seconds left. Gordon made two more free throws after that for the final margin.

"We were confident throughout the game that we were going to win the game," Carson said. "In overtime we are still going to be as confident as we were at the beginning of the game. We didn't think they could beat us."

Fontan led the Trojans (8-12, 3-4) with 25 points and Terrell scored 20. Eric Wise had 19 points for the Trojans.

USC lost for the second time in three games under Cantu, who took over when Kevin O'Neill was fired. The Trojans have lost four of their last five, and all three of their games under Cantu have been decided by five points or fewer.

Carson had four points during a key 8-0 run for the Sun Devils that gave Arizona State a 77-69 lead with 3:29 remaining.

Carrick Felix added 16 points and 10 rebounds for Arizona State, which had won six straight before losing to No. 16 Oregon and No. 6 Arizona.

Felix had 11 points as Arizona State opened up a 37-29 lead with 3:45 left in the first half. But Wise scored five points in the final minute to help Southern California tie the game at 42 going into the break.

Fontan had 13 points and two assists in the first half for the Trojans.

"There are little things that need to be adjusted and I think we can move forward and have success," Cantu said.