Charlie Baker launched his gubernatorial campaign last year in Lowell, and he spent much of the campaign chasing votes in cities that are traditionally hostile to Republicans like himself. Baker made raiding Democratic votes in Massachusetts cities a cornerstone of his campaign strategy. He scored a narrow victory Tuesday evening over his Democratic opponent, Attorney General Martha Coakley, even though he only made inroads in a handful of key cities. Coakley’s biggest struggles came not in the cities she was defending against Baker, but in stalwart liberal suburbs.

Lowell shows the shortcomings in Baker’s urban offensive. Scott Brown turned the city red in his 2010 Senate contest against Coakley, winning the city by 5 percentage points. Gov. Deval Patrick made cities such as Lowell a cornerstone of his 2010 reelection effort, and he beat Baker by more than 8 points in the city four years ago. Baker threw everything he had at Lowell, barnstorming through the city repeatedly, and winning the endorsement of the Sun and Democratic state Rep. David Nangle. But Coakley won the city by 7 points, just 1 point shy of Patrick’s 2010 mark.

Coakley held her own in several cities Baker coveted, such as Lawrence, Chelsea, Framingham, Salem, and Lynn. In all those cities, Coakley exceeded her own 2010 showing, and ran closely behind Patrick’s 2010 pace. In taking Brockton by 25 points, she ran 4 points ahead of Patrick’s reelection effort.

Baker made Boston a cornerstone of his campaign efforts. The state’s largest city has swung far to the left over the past decade. In 2002, Democratic gubernatorial nominee Shannon O’Brien took the city by 29 points; recently, Boston voters handed Patrick and Elizabeth Warren margins of victory of 47 and 49 points, respectively. Baker made modest inroads in Boston. He lost the city by 36 points – a mark that’s just below the 38-point defeat Coakley dealt Brown in Boston.

Baker did far better in Quincy, where Coakley’s prosecution of former state Treasurer Tim Cahill won her plenty of enmity. Quincy Mayor Thomas Koch, whose inner circle includes many Cahill loyalists, endorsed Baker, and Koch delivered. Baker won the city by 4 points – an 11-point swing from Patrick’s 2010 victory there. Baker also ran relatively strongly in Worcester, where he stayed within 11 points of Coakley, and in Springfield, where he shaved 11 points off the margin that separated him from Patrick in 2010.

The most surprising returns came not from the cities Baker had campaigned so hard in, but in the wealthier liberal Boston suburbs. Coakley was unexpectedly weak in the belt of bedroom communities surrounding Boston, as huge numbers of voters who had backed her in 2010 embraced Baker, a Republican who’s fiscally conservative but socially liberal.

Coakley ran 13 points behind her own 2010 pace in Newton, winning the liberal stronghold by just 20 points; in 2010, Patrick had taken it by 37. Coakley’s 2010 Senate campaign essentially ran even with Patrick’s reelection campaign in neighboring Brookline, but on Tuesday Coakley fell 11 points behind her 2010 mark. Patrick won Sharon by nearly 18 points four years ago, but Coakley took the suburb by less than 2. The same story played out in Lincoln, Lexington, Acton, Concord, Natick, and Wayland. Coakley lost Milton by 1 point and Carlisle by 2, making Baker the first statewide Republican to capture either town since Mitt Romney in 2002.