The monthslong coverage and criticism of City Hall aide Rachel Noerdlinger ended this week when she temporarily stepped down from her post following the arrest of her young son.

Mayor Bill de Blasio's support for Noerdlinger -- beleaguered by stories about her boyfriend's criminal past and her issues with creditors -- was politically expensive. In fact, the cost was so high that we can conclude his loyalty was genuine, and not communications strategy.

Noerdlinger cost the de Blasio administration in myriad ways.

First, the punishing coverage blocked out City Hall's agenda, making it difficult to advance the conversation on the issues important to them while limiting their ability to tout successes. The day after Noerdlinger stepped down, for instance, the city's front pages blared headlines about her departure, and not about a report that crime is now at its lowest rate in 20 years.

It's also worth noting that a poll this week showed stagnant approval for the mayor among voters, despite a safe city and a lower local unemployment rate than at any time during Mayor Michael Bloomberg's final term.

Second, the story line allowed de Blasio detractors to pile on with negative narratives they'd like to push about his administration. The fact that Noerdlinger was a former aide of the Rev. Al Sharpton -- who de Blasio critics have argued is too close to the mayor -- was among the most prominent.

Third, the mayor damaged an already strained relationship with the media. He was defiant throughout the stories on Noerdlinger, sticking by his staffer and railing against the outlets writing about her. That all came to a head on Monday, when the mayor became visibly angry during a news conference, slamming reporters' interest in Noerdlinger's off-duty life as "repulsive."

Perhaps the mayor should have considered Mark Twain's famous warning ("Never pick a fight with people who buy ink by the barrel") first, because that outburst could not have played more poorly the next day.

But de Blasio, a former political operative, no doubt knew his response would be criticized -- and that coldly cutting Noerdlinger loose would have saved his image and agenda from attack. Indeed, the vast majority of other politicians would have done just that without a second thought. Yet, right or wrong, he clearly believed that Noerdlinger was unfairly maligned. So he stuck to his guns.

It's not the first time. Ideological defiance won de Blasio the universal pre-K program he considered a moral imperative, but it also lost him bandwidth for his agenda during a prolonged attempt to curb the horse carriage industry.

Voters, of course, want a principled approach from their mayor. But productive government work requires amassing and spending political capital -- and that means compromise. Progress is hard to come by, and it often takes years at a grind to get anything done in areas the average citizen would consider vitally important. Persistent distractions such as staff scandals throw a wrench in that machine.

So the mayor's defiant style leaves an open question for New Yorkers: whether or not you agree with the mayor, would you prefer he stick to his principles, even if it is arguably at the expense of other priorities, or would you prefer a purely political approach that is perhaps more effective?

Unfortunately, governing often requires that hard choice. Ultimately, the mayor, and New Yorkers, have to decide how high is too high a cost for uncompromising defiance.

Evan Thies is the president of Brooklyn Strategies, a public affairs and strategic planning firm that offers political advice.