The shootings happened Sunday in Woburn, a city of about 40,000 residents just north of Boston.
The officer was shot dead while responding to a robbery in progress at a Kohl's department store, police and prosecutors said. He was transported to a hospital, where he died.
One suspect was shot dead by responding officers, Middlesex District Attorney Gerry Leone and Woburn police Chief Philip Mahoney said.
"This is a horribly tragic incident in which an officer was fatally shot in the line of duty," Leone said in an e-mailed statement.
He said his "thoughts and prayers" were with the family of the officer, whose identity wasn't disclosed because the officer's family hadn't been notified.
The identities of the three suspects hadn't been determined, police and prosecutors said.