The final count was 37,323-35,641, announced in a text message to the Daily News by the Rausch campaign.

Rausch texted at approximately 1:20 a.m. Wednesday, "WE WON!!!! Pending confirmation of all the numbers, but we are confident." The outcome hung on the result from Attleboro, the last of the 12 communities in the district to report. Attleboro went 3,387-3,055 for Ross.

WE WON!!!! Pending confirmation of all the numbers, but we are confident.

&mdash; Becca Rausch for MA Senate (@Becca4MASenate)November 7, 2018

Before returns started coming in Tuesday night, Ross said he would be "absolutely shocked" if he lost to Rausch. That comment was made as Ross, an eight-year incumbent, and his staff spent election night at Morin's Hometown Bar and Grill in Attleboro waiting for returns.

The vote was split geographically, as Rausch swept the north section of the district, while Ross made a clean sweep in the south.

"The election process is imperfect," Ross said minutes before he left the Attleboro bar shortly after midnight with the race undecided. He trailed by several hundred votes at the time. "I accept it for what it is."

Rausch nearly tripled Ross when it came to their respective campaign war chests in the general election - $64,437 to $22,711, according to the Massachusetts Office of Campaign and Political Finance.

An attorney and Needham Town Meeting member, Rausch billed herself as the more progressive choice, more in line with what voters care about, including affordable health care and transportation issues. Rausch took 57 percent of the vote in the Democratic primary, outpacing Wellesley High School teacher Jackie Katz and Wayland lawyer Kris Alexsov.

Ross ran unopposed in the Republican primary.

Twice last month, Ross declined invitations to debate Rausch. He did not respond to an invitation to attend a public forum sponsored by the League of Woman Voters in Wellesley, Wayland and Needham. Ross didn’t answer two emails and five phone calls, according to the LWV, that invited him to attend a forum to be shown on Wayland Public Access Television. A scheduling conflict prevented Ross from attending a forum sponsored by MassEquality, which endorsed Rausch before the Democratic primary. The grassroots organization bills itself as the leading advocacy group for LGBTQ equality in Massachusetts.

Ross acknowledged Tuesday night that he didn't debate Rausch, because he didn't want to give a relative unknown any momentum.

"All along, nobody knew of my opponent," Ross said. "(A debate) gives her a chance to become more popular. There was no upside for me to debate her."

Ross touted a perfect roll-call vote attendance record in this year’s legislative session, according to a September statement from his office. It’s the seventh straight session Ross has achieved the mark, the statement said.

Ross has served the district since 2010. He won a special election to replace Scott Brown, who defeated former state Attorney General Martha Coakley in a special election to finish out the term of the late U.S. Sen. Ted Kennedy.

Follow Henry Schwan on Twitter @henrymetrowest. He can be reached at hschwan@wickedlocal.com or 508-626-3964.