When reliever Connor Higgins struck out Arizona’s leading hitter, JJ Matijevic, with the bases loaded and no outs in the seventh inning Thursday night, Arizona State had hope of escaping a major jam in a tie game.

Instead, No. 19 UA scored two runs on a sacrifice bunt and another on the inning’s second error to take a three-run lead in a 6-5 victory at Phoenix Municipal Stadium.

By winning the Pac-12 rivalry series opener, the Wildcats (34-17, 13-12 Pac-12) took a 2-1 season series lead over ASU (23-27, 8-17).

The top of the seventh started badly for ASU with a fielding error by shortstop Andrew Snow. Tiring starter Eder Erives walked Cal Stevenson on four pitches and Jared Oliva singled to left, loading the bases. ASU coach Tracy Smith brought in Higgins, who fanned Matijevic on three pitches.

Alfonso Rivas bunted toward first base and was thrown out by Higgins but not before two runs scored. A third unearned run came across on Snow’s second error of the inning, a low throw to first base.

Erives (1-4) took the loss despite one of his best senior outings in his final home appearance. He worked six-plus innings with six hits and three earned runs.

Zach Cerbo hit a solo home run in the bottom of the seventh, but ASU could not overcome a third deficit like it did when trailing 1-0 and 3-1. The Sun Devils stranded two in the eighth and one at second base in the ninth after scoring their final run on a passed ball.

“That’s one for the taking tonight,” ASU coach Tracy Smith said. “We had a couple of miscues. We make the plays defensively, we’re probably coming out of here with a different result. That’s been a little bit of our song all season. We have not had solid middle infield play, which is something we plan to address moving forward. But I’m not going to fault the effort on the guys. They kept battling.”

Second baseman Carter Aldrete, who had three hits, said, “Eder threw his tail off tonight. If would have gone way better if we had capitalized defensively, but that’s how it goes sometimes. We had to play the elements and defensively we didn’t support him as well as we want to.”

Matijevic broke a 1-1 tie in the fifth with a two-out, two-run double to the right field corner off Erives.

ASU’s Gage Canning cut the deficit in the fifth with his team-high sixth home run, a one-out solo shot to right field. Then with the bases loaded and two outs, UA starter JC Cloney threw an 0-2 wild pitch to Carter Aldrete, scoring the tying run.

Cloney exited after 5 1/3 innings, giving up six hits and three runs with seven strikeouts.

UA can clinch the Territorial Cup Series point with a win in one of the remaining two games, at 7 p.m. Friday and Saturday.

ASU already has clinched the overall Territorial Cup Series title for a fourth consecutive year, leading 10.5 points to 8.5.

The Sun Devils must win their remaining five games to avoid its first losing season since 1985 and second ever in the varsity era going back to 1959.

Arizona went hitless through the first three innings on Thursday before breaking through in the fourth.

Stevenson led off with a double to center that Canning misplayed due to a tricky wind that affected fly balls for the first six innings. With one out, Erives hit Matijevic, who started the night hitting .402, seventh-best in the nation. Alfonso Rivas singled to short left in between Snow and outfielder Myles Denson to score Stevenson. Another hit batter loaded the bases, but Erives escaped further damage by getting an infield fly and ground out.

ASU got the tying run back in the fourth off Cloney. Cerbo walked with one out, moving to third on a hit-and-run single by Aldrete. Snow’s sac fly to right scored Cerbo.

Erives pitched 1 2/3 innings of relief at Arizona on May 9, holding on in a 14-13 victory for his first win of the season. UA won the first rivalry meeting 11-2 on April 4.

Cloney worked a clean first inning but needed 20 pitches to do so including 10 to strike out leadoff batter Canning.

In the ASU second, Lyle Lin and Aldrete singled with a strikeout in between but neither scored as Snow and Jeremy McCuin flied out.

Arizona at ASU preview

The Sun Devils (23-26, 8-16 Pac-12) play their final home series of the season against No. 19 Arizona (33-17, 12-12) with the Territorial Cup Series point at stake.

Perhaps more importantly, the Sun Devils are fighting to avoid what would be only the second losing season in the program’s 59-year history

ASU and UA split two non-conference games this season, both in Tucson, with ASU losing 11-2 on April 4 and winning 14-13 on May 9.

RELATED: Pac-12 baseball standings

The Sun Devils already have clinched a fourth straight undisputed Territorial Cup Series title, leading 10.5 points to 8.5. ASU went 3-2 against UA from 2014-16.

Sun Devils need strong finish

To avoid its first losing season since 1985, ASU must finish at least 5-1 against UA and at Utah.

The Sun Devils are coming off a 2-2 trip to Washington that included a 6-4 comeback win over Seattle on Tuesday. 3B Jeremy McCuin has seven hits in the last three games. Freshman Myles Denson has played left field in the last four games.

The trip also was marked by the end of ASU’s 54-year streak of winning at least 30 games with a 4-0 defeat at Washington on Sunday.

Wildcats angling for postseason

UA won their last two games at College of Charleston to take that non-conference series. The Wildcats are seeking to clinch a berth in the NCAA Tournament to compete for a return trip to the College World Series.

The Wildcats are home against California after playing ASU before the 64-team NCAA field is announced May 29.

1B JJ Matijevic is hitting .402 with 10 home runs, 57 RBI and a .672 slugging percentage. Pitcher JC Cloney is 7-1 with a 2.64 ERA. UA last won the rivalry series in 2013 (3-2).

Arizona at Arizona State

When: 6 p.m. Thursday, 7 p.m. Friday and Saturday.

Where: Phoenix Municipal Stadium.

TV: Pac-12 Network.

Radio: KDUS-AM (1060).

Remaining games

Friday, May 26 – ASU at Utah, 10:30 a.m., Pac-12 Networks

Saturday, May 27 – ASU at Utah, 10:30 a.m., Pac-12 Networks

Sunday, May 28 – ASU at Utah, 10:30 a.m., Pac-12 Networks

Tuesday: ASU baseball 6, Seattle 4

Arizona State scored four runs in the seventh inning to rally past host Seattle for a 6-4 win on Tuesday.

The Sun Devils were led by Jeremy McCuin, who went 3-for-4 with two RBIs, and Zach Cerbo, who had a 2-for-3 night with a home run and two walks.

ASU (23-26) returns to Phoenix Municipal Stadium on Thursday to open a three-game series against rival Arizona (33-17). The Sun Devils and Wildcats split a pair of non-conference games earlier this season.

The Sun Devils need to win six of their final seven games to avoid their first losing season since 1985 and second in school varsity history (not including 2007 when 44 wins were vacated due to NCAA sanctions).