As the players and coaches of the Williamsport baseball team gathered in front of the third base dugout for a commemorative photo after their 2-1 victory in nine innings over Patuxent in the Maryland 2A championship at Ripken Stadium on Saturday afternoon, each clutched his trophy and made sure everyone could see six fingers held aloft.

It has been a trying three weeks since the Wildcats’ best player, Brendon Colliflower, died in a car accident that also claimed the life of classmate Samantha Kelly as they drove home from the school prom on May 5.

For a week, Coach David Warrenfeltz said, the team gathered at the school’s baseball field but did not practice. Then there was the second-round playoff game hours after the funeral for Colliflower, who was considered one of the state’s top high school baseball players and planned to play next year for Salisbury University.

Somehow, a squad that finished .500 in the regular season — losing its final three games by a combined 31-3 — righted its ways. And when Brandon Toloso got down a suicide squeeze bunt with one out in the bottom of the ninth inning to score Tyler Martin from third base, Williamsport (15-9) claimed its first state title since 1975. The players with Colliflower’s jersey No. 6 stitched in their hats and wrist bands could finally rejoice.

“Losing Brendon and Sam, it brought us together as a family, as you can see,” Warrenfeltz said. “I was just hoping we were something our community could rally around and people could get excited about for a couple weeks.”

Warrenfeltz had endured trying times before. A 2005 Williamsport graduate, he was a teammate of the late Nick Adenhart, who went on to pitch for the Los Angeles Angels but was killed in a car accident by a drunk driver in 2009.

“Going through that was hard, but this was tough because it wasn’t just me hurting,” said Warrenfeltz, who lives in Williamsport and teaches elementary school in Hagerstown. “Being around high school kids and feeling their hurting and there was nothing I could do about it.”

Patuxent, vying for its first state title, had tied the game at 1 in the seventh inning as Preston Ross’s squeeze bunt brought home Tyler Crounse. But the Panthers (19-5) could not push across another run.

“Williamsport has been through a lot this year,” Patuxent Coach Keith Powell said. “They battled. They’re a great story. . . . They’re very deserving.”