The Democrats held on to James Timilty’s state Senate seat Tuesday night, as Foxboro’s Paul Feeney beat Attleboro Republican Jacob Ventura by a margin of 47 percent to 43 percent.

Medfield independent candidate and former journalist Joe Shortsleeve received around 9 percent of the vote.

The special election was necessary because Timilty announced in April that he would resign to take the job as Norfolk County treasurer.

The Bristol Norfolk district covers Mansfield, Norton, Rehoboth, Seekonk, Foxboro, Medfield, Walpole and parts of Attleboro and Sharon.

The race was close with seven of the nine towns reporting. Before Attleboro and Sharon’s results were tallied, Ventura was leading by a slim margin of 0.7 percent. After winning Sharon by 709 to 190, Feeney’s win was secure.

Feeney rounded out the evening by winning Attleboro 1,079 to 940.

The race was close, with four towns voting Republican and five voting Democrat. Mansfield, Norton, and Foxboro joined Sharon and Attleboro in voting for Feeney.

Feeney’s biggest win outside of Sharon was in his hometown, where Foxboro voters chose him 1,029 to 727.

Ventura won big in the southern part of the district

The tightest race was in Walpole, where Ventura won 1,219 to 1,209.

Shortsleeve performed best in his hometown of Medfield, where he received 21 percent of the vote.

FEENEY VENTURA SHORTSLEEVE Democrat Republican Independent Attleboro 1,079 940 156 Foxboro 1,029 727 167 Mansfield 1,071 783 228 Medfield 498 564 289 Norton 627 562 82 Rehoboth 368 671 67 Seekonk 392 749 80 Sharon 709 190 51 Walpole 1,209 1219 235 6,982 6,405 1,355 47% 43% 9%