When Sean Collier couldn’t get onto the 130-member Somerville Police Department in Massachusetts, its ranks full and hiring list long, the recent college graduate volunteered for the city’s auxiliary force, keeping watch over parks, playgrounds and schools.

He took an unglamorous civilian job in the police records room, where he built a Web page and introduced Twitter and Facebook to cops mired in old ways. He left in January 2012 when a spot opened up in neighboring Cambridge, policing the grounds of the prestigious Massachusetts Institute of Technology. He engaged and protected students, at ease conversing in high-tech language and joining the MIT Outing Club on skiing and hiking trips.

But Collier never took his name off the civil service list in Somerville, and he slowly crept to the top as officers departed and replacements were chosen. The deputy chief said he was on the verge of hiring the 26-year-old officer when bullets fired late Thursday by one or both of the suspected Boston bombers ended his lifelong dream.

Collier was found shot multiple times in his cruiser next to a cancer research building at MIT, about 10 minutes after police received reports of shots fired on campus. The circumstances of the shooting remain under investigation.

The officer died at Massachusetts General Hospital, a casualty in a long night of violence in the Boston suburbs linked to the bombings at the finish line of Monday’s Boston Marathon. After a police chase through Cambridge and into Watertown, a transit police officer, Richard Donohue Jr., 33, was seriously wounded in an exchange of gunfire.

Being a cop, said Somerville Deputy Police Chief Paul Upton, “is what Sean wanted to do. He wanted to do it here. And he wanted to be good at it. This is a huge loss to the MIT police department. And though he hadn’t started here yet, it’s already a huge loss for us.”

The officer’s neighbors in Somerville gathered Friday for a vigil, and some dropped flowers at his apartment door, according to local media accounts. Some of Collier’s relatives, reached at their home 15 miles northeast of Boston, said they did not want to talk, but several news organizations published a statement from them.

“Our only solace is that Sean died bravely doing what he committed his life to — serving and protecting others,” the family said. “We are thankful for the outpouring of support and condolences offered by so many people.” Collier’s 25-year-old brother, Andrew, works as a machinist for Hendrick Motorsports, which races in NASCAR’s Sprint Cup series.

Collier grew up in Wilmington, Mass., a bedroom community incorporated in 1730 and run by selectmen and the New England-style town meeting. He graduated from Wilmington High School in 2004 and enrolled in the criminal justice program at Salem State University. He graduated near the top of his class in 2009.

After graduation, Collier moved into an apartment in Somerville, a Boston suburb with a population nearly four times that of his home town packed into five times less space. He quickly fell in love with the place. At the police department, Collier used his Internet prowess to bring the department into the modern era and to converse in social media, according to Upton, the deputy chief.

Collier quickly made friends in high places. Somerville Mayor Joseph Curtatone said Collier “brought a cutting-edge approach to his everyday work.”

Members of the MIT hiking club posted a tribute to Collier on the university’s Web page with stories of his travels to sub-zero temperature zones in Newfoundland, where he hiked rugged peaks, munching on pepperoni. “His grin was irrepressible,” fellow hikers wrote. They noted Collier’s penchant for telling stories on long car trips, recalling not only the anniversary of the first winter climb of Mount Everest but also knowing it was by a Polish citizen named Krzysztof Wielicki.

“So feel free to bring any Polish dishes, wear Poland’s colors (red and white), bring a Polish flag (because you know you have one laying around your apartment), or just actually be from Poland (cool!) to commemorate this awesome feat,” they quoted from one of Collier’s notes.

Curtatone, the mayor, had just returned from a vigil for the marathon when the police chief called him about Collier. He and his city had another person to mourn.

Collier would have been immersed in the hunt for the bombers no matter which department he worked for. Norfolk Street, where the suspects lived in Cambridge, ends at the Somerville line; when the “officer down” call screamed across police radios Thursday night, Somerville officers rushed to MIT to help. At least one knew Collier.

“Every police employee is working today with a heavy heart,” Upton said. “This was a senseless killing of a young, vibrant 26-year-old who had his whole career and his whole life to look forward to and wanted nothing more than to serve the public.”