ON HIS WAY to a landslide victory this week, Charlie Baker did something unusual for a Republican these days. He won urban areas, pulling 55 percent in the state’s 20 largest cities and towns, according to unofficial returns from the AP.

This is not normal fare for our politics here in Massachusetts, or really anywhere these days. Nationally, Republicans earned just 29 percent of the vote in urban areas last week, according to exit polls from Fox News and the AP. Democrats typically need to maintain enormous margins in cities to offset losses elsewhere in more rural areas.

You can’t win most urban areas without a diverse coalition, an impossible task for most Republicans these days. Black and Latino voters, in particular, have rejected most Republican candidates in overwhelming numbers in recent elections. In 2016, President Trump earned just 8 percent support among black voters, and 28 percent among Latinos. This year, Republicans nationally earned similar shares, reflecting the deep polarization of our politics along racial lines.

Baker’s performance in cities was no accident. Courting urban leaders and voters was a major part of his campaign strategy in 2014, and he’s kept at it since his election. His administration’s economic development policy lavished attention and funding on cities, particular cities outside of the greater Boston area. The administration followed through on a 2014 campaign promise and created a grant program focused on urban neighborhoods.  Holyoke benefited from infrastructure and economic developments grants. The administration launched a task force to revitalize Lynn. Lowell and Worcester benefited from research and manufacturing grants.

Baker himself cited his administration’s work in cities as a reason for his success there. “People have seen a lot of us on the ground in their communities and they’ve seen our cabinet in their communities,” he said at a press conference the day after the election in response to a question about his nearly winning Boston and Lawrence. “We’re not strangers to Lawrence. We’re not strangers to Boston. We’re not strangers to Springfield or Worcester or Pittsfield or Fall River and New Bedford and a whole bunch of other communities where the voters were kind enough to turn out on our behalf.”

These urban initiatives helped Baker develop relationships with the mayors and other political leaders in these cities. Alex Morse, Holyoke’s young mayor, testified alongside Baker in support of his economic development bill. Twenty-two mayors endorsed Baker’s reelection bid, including 10 Democrats. Lawrence Mayor Dan Rivera even was featured in Baker campaign TV ads, and Baker came within 60 votes of winning the heavily Latino city.

These programs were part of policies designed to expand economic growth beyond Boston. But these election results suggest they had a political benefit as well. In 2018, Baker went from stemming the blue tide in these cities to swamping them with his own votes. Baker won many of these cities outright, some by double digits.

The warning signs were evident in the primary, when more than 20 percent of Democratic primary voters blanked the governor’s race. Democratic voters came to choose candidates for other races, but showed little interest in replacing Baker. The 22 cities whose mayors endorsed Baker over Gonzalez had an above-average rate of blanked ballots. By campaigning and governing in cities that another Republican might have overlooked, Baker effectively cut off support for a Democratic challenge before the campaign even got underway.

It showed up in the vote totals. In the Democratic powerhouse of Boston, where Mayor Marty Walsh has worked closely with Baker during his first term, the governor and Gonzalez were within a point of one another. In many of the other smaller cities dotting the state, Baker ran up lopsided wins.

In Baker’s case, familiarity with these Democratic strongholds bred Republican votes. It’s a lesson Democrats would do well to learn if they want to end their gubernatorial drought.

Rich Parr is the research director and Steve Koczela is the president of the MassINC Polling Group, a subsidiary of MassINC, which publishes CommonWealth.