Two undefeated teams playing on the state’s biggest stage. Two coaches with more than 500 wins. Two of the state’s best Division I recruits.

There were big expectations for the Class A girls’ basketball state championship game Saturday.

York and Lawrence met each one of them.

York sent Coach Rick Clark into retirement with his fourth state title, beating Lawrence 58-57 in a scintillating game at Cross Insurance Arena. The game featured five times and 13 lead changes – the last coming with 62 seconds remaining when Chloe Smedley hit a jump shot to put York ahead.

Clark’s 34th season with the Wildcats ended with a 22-0 record. Lawrence, the defending Class A champion, finished 21-1.

“I have no words right now,” said York’s Shannon Todd, clutching the Gold Ball. “It’s surreal, winning a state championship.”

Both teams made adjustments, then counter-adjustments. Both teams saw their star players – Nia Irving for Lawrence; Todd and Smedley for York – get into foul trouble. York had the size advantage and used it at both ends, its taller defenders forcing 17 Lawrence turnovers (York had only eight). Lawrence rained down 3-pointers, connecting on 8 of 20. All of that combined for a game that will be remembered for a long time.

“This is awesome,” said Smedley, who hit 10 of 14 shots to score 23 points, while grabbing five rebounds and handing out four assists. “This is what we were all in it for, it’s what we worked for.”

Lawrence led 17-12 after one quarter, but the Wildcats roared back to lead 32-30 at the half. And when Irving, the state’s best inside player, picked up her third and fourth fouls within 13 seconds early in the third, York led by five.

But the Bulldogs showed their championship pedigree. Dominique Lewis (19 points) scored six points, and her 3-pointer gave Lawrence a 45-44 lead. Then Morgan Boudreau’s three-point play made it 48-44 entering the fourth.

“I give my kids credit when Nia went down with four fouls,” said Lawrence Coach John Donato. “Our biggest kid on the floor was 5-5 and we stayed with them. The kids did step up.

“It’s a tough pill to swallow, but they shot the ball very well … And we didn’t shoot as well as we have been. I think the stage was a little bit overwhelming for us, especially my young kids.”

A Lewis 3-pointer gave the Bulldogs a 53-49 lead with 5:19 left. Maddie Cogger hit a 3-pointer, then passed to Morgan Chapman for a layup and a 54-53 York lead.

Molly Folsom scored to make it 55-54 Lawrence with 1:31 left.

Then Smedley took a pass from Mia Briggs at the left elbow and calmly drained the jumper for the go-ahead basket.

“I was so confident in that shot. I had to take it,” said Smedley. “I knew we needed to go up. I shot it and I was praying that it would go in. And it went in. Awesome.”

A Lawrence traveling violation gave York the ball again. Lily Posternak alertly found Todd uncovered under the basket for a layup and a 58-55 lead with 19 seconds left.

Lawrence had one more chance, but its 3-point attempt went off the rim and Irving (14 points, 11 rebounds) scored on an offensive rebound with one second left – not enough time to do anything more.

“It was like it was in slow motion,” said Clark. “We had the rebound but lost it and Nia picked it up. All I could say was, ‘Don’t foul her’.

“The ball went in and … all of a sudden, it’s over. I had to look at the scoreboard a second time to make sure we were up by one.”

Clark had told his players last summer he was retiring. At the time, they said a championship would be a storybook ending.

Clark told them that would be nice, then added, “Fairy tales don’t always end the way you want them to.

“This one did.”