Incumbent Democratic US Representative William Keating fended off a challenge by Republican attorney John Chapman, a former Reagan White House aide and Romney administration official, the Associated Press projected.
The Ninth District covers much of the South Shore and Cape Cod.
Democratic US Representative Niki Tsongas of Lowell also will hold onto her seat, the AP projected, easily beating her Republican challenger. Tsongas had faced Roseann L. Ehrhard Wofford of Haverhill.
In the Sixth District, which covers the North Shore and parts of the Merrimack Valley, Democrat Seth Moulton unseated incumbent John F. Tierney in the September primary. The Iraq War veteran, a political newcomer, defeated Republican Richard R. Tisei in a hotly contested, high-profile race.
The state's six other congressman, First District Democrat Richard E. Neal, Second District Democrat James P. McGovern, Fourth District Democrat Joseph P. Kennedy III, Fifth District Democrat Katherine M. Clark, Seventh District Democrat Michael E. Capuano, and Eighth District Democrat Stephen F. Lynch, were all unopposed.