LOS GATOS — It was not until the final batter in a third and decisive game that the Palo Alto baseball team could finally exhale.

The Vikings held off Los Gatos 6-4 on Friday to win the best-of-three series and advance to the championship round next week in the Santa Clara Valley Athletic League De Anza Division playoffs.

“The boys came together and played tough, good baseball,” Palo Alto coach Pete Fukuhara said.

Palo Alto got strong pitching from starter Isaac Kasevich and big hits, particularly from the lower third of the order, but Los Gatos (26-4) did what it has done so often this season.

It kept rallying.

Palo Alto led 6-2 after Owen Plambeck’s single in the top of the seventh drove in two runs. But Los Gatos scored two in the bottom of the seventh and had two runners on when a force out at second ended the game.

The Vikings move on to play a best-of-three series against Saratoga, which rallied to beat Wilcox 9-8 in the third game of their series Friday.

The winner next week will share the league championship with Los Gatos and Wilcox, which tied for first in the regular season, and will automatically join the co-regular-season champs in the Central Coast Section Open Division playoffs.

“The win today put us in a good position,” said Kasevich, who allowed two runs in 5 ⅓ innings. “We really want to be in the Open Division.”

Palo Alto opened the series with a 1-0 win at Los Gatos on Tuesday, and Los Gatos rebounded with a 5-3 victory at Palo Alto on Thursday.

Friday, Palo Alto (17-12) grabbed the lead in the second when Riley Schoeben hit an infield single off the pitcher with the bases loaded.

Los Gatos evened the score in the third on Ryan Gault’s RBI single.

Ethan Stern’s double to center in the fourth drove in Justin Hull to give Palo Alto a 2-1 advantage, and Jack Andrews’ home run in the fifth would have stretched the lead to 3-1.

But after celebrating with teammates, Andrews was called out for not touching home plate.

Palo Alto added to its lead an inning later when No. 7 hitter Alec Olmstead hit a line single to left to make it 4-1.

In all, the bottom third of Palo Alto’s order knocked in four runs.

“I really feel like our team is good enough to where we can produce throughout the entire order,” Olmstead said. “We just really wanted to win this game.”

The three-run cushion wasn’t safe, though.

Aiden Finch hit a home run to left to lead off the sixth for Los Gatos, and the Wildcats loaded the bases with one out. But Stern, Palo Alto’s shortstop, caught a soft liner up the middle and stepped on second for a double play.

Los Gatos rallied again in the seventh before Palo Alto closed it out.

“They are a great team,” Olmstead said of Los Gatos. “These guys battle. They have great pitching, they can really hit and they play the game really hard. I respect these guys a lot. It was a great win.”

The loss was Los Gatos’ third in nine games since opening the season with a 20-1 record.

“Whenever you’re faced with adversity, you get tougher if you can overcome it,” Anderson said. “To be honest, with the record the way it is, we haven’t faced as much adversity as a lot of teams because a lot of people didn’t expect us to start off so hot — and we did knock off some powerhouses.

“But all of a sudden when you have a target on your back, everyone is going to show up with their best game. This time of the year, when you don’t show up with the energy and the effort and the execution like you usually do, you’re going to lose.”