The Democrat led Somerville for 18 years, gaining popularity among progressives for his stances on climate change, racial justice and education.