WORCESTER >> Just like it did throughout its magical run to Polar Park, the Chelmsford High baseball team found a way.

The Lions delivered multiple winning recipes en route to the Division 1 state championship game on Friday. Be it a 12-run offensive explosion over the highly regarded Bishop Feehan or a two-run defensive duel over perennial power Saint John’s, No. 14 Chelmsford clinched victories in a myriad of ways to pull upset after upset.

Friday night was no different. Backboned by ace pitcher Matt Stuart, who racked up four clutch strikeouts in extras, the Lions edged No. 8 Braintree, 8-2, in a nine-inning thriller at Polar Park to claim their first state title in the MIAA era. Chelmsford’s only other state baseball championship came in 1966.

Aidan Brackett delivered the game-winning hit in the ninth, a one-run single with the bases loaded, before a sacrifice fly by Matthew Hall opened the floodgates for a six-run ninth. John Latham plated two Chelmsford runners on a Braintree error as the inning continued with a wild pitch and an RBI from Will Colucci to seal the win.

Stuart retired the Braintree side in the home half to put the finishing touches on his complete-game marathon.

Chelmsford’s improbable run yielded wins over No. 19 Shrewsbury (1-0), No. 3 Bishop Feehan (12-3), No. 11 Wellesley (1-0) and No. 2 Saint John’s (5-3). The Lions finish an impressive season with a 19-8 record.

Braintree (16-9) knocked a trio of consecutive hits en route to taking a 1-0 lead thanks to a base hit off the bat of Owen Donnelly. Peter Brooks then slapped a blooper to center field that found grass, moving Donnelly to third with two outs in the inning. Connor Grieve’s chopper to right field then plated Donnelly as Braintree broke the ice. A sliding grab by center fielder Latham ended the inning with runners on the corners.

The Lions nearly evened the score after lacing three hits in the fourth from Stuart, Brackett and Hall. But with the bases loaded and one out, Braintree’s Michael Ryan turned an unassisted double play to escape the inning unscathed.

However, Stuart retired the side in the home half to prevent any Braintree momentum.

And when Chelmsford juiced the bases for the second consecutive frame in the fifth, the Lions broke through to take a 2-1 lead after a Braintree error on a fly ball along the first base line scored two runners.

Keegan Briere, Will Colucci and Evan Kobrenski reached base with one out in the frame when Joyce struck out Stuart to position the Wamps one out away from escaping yet again. But after a pop-up by Jack Keyo was misplayed by Braintree, Chelmsford took advantage by running on contact and scoring a pair of runs.

The Chelmsford defense helped its cause in the inning to nurse its 2-1 lead into the sixth. After Latham chased down a deep shot to left and relayed the ball to the infield to double up a Braintree runner on first, Colucci made a diving catch to end the inning.

The Lions made more noise in the sixth but couldn’t tack on an insurance run as Finn Ramseyer was thrown out at the plate on a ground ball dribbled to third after a double from Latham.

The Wamps answered in the bottom half on an RBI single from Matt Rogers to knot the game at 2-2 ahead of the seventh, where the Lions had the winning run at their fingertips. After a double by Stuart and a single by Keyo placed two runners in scoring position, Rogers relieved Joyce of his duties on the mound and recorded two pivotal outs.

Chelmsford was on the brink of elimination in the seventh with the winning run on second, but Stuart dug deep to record a strikeout to send the game to extras. Still in the game, the Lions’ hurler posted another key punchout in the eighth with a Braintree runner in scoring position for his sixth strikeout of the night — four of which came in the seventh and eighth.