The attack in Boulder ended with police detaining an injured, shirtless suspect at the King Soopers market.
The shooting was live-streamed by witnesses and broadcast on YouTube.
The incident began at about 14:30 local time (20:30 GMT) on Monday when the suspect entered the supermarket and began firing.
About 20 minutes later, the Boulder police department tweeted that there was an “Active Shooter at the King Soopers on Table Mesa” street.
Police again warned people to avoid the area in a further tweet about two hours later. “Do NOT broadcast on social media any tactical information you might see,” the tweet added.
However, some of the stand-off was captured on camera by a passer-by showing victims near the grocery store.
“I don’t know what’s going on… I heard gunshots, someone’s down,” the cameraman shouts. “There’s an active shooter, get away”.
Gunshots can be heard as he runs away from the shop.
The video continues, with police arriving on the scene and surrounding the market.
People said they had to dive for cover or run to safety as the shooting unfolded.
Aerial footage later showed a man, who appeared only to be wearing shorts, being taken away in handcuffs.
Speaking at a press conference, Boulder police chief Maris Herold confirmed that a suspect was in custody and was receiving hospital treatment. “I want to reassure the community that they are safe,” she said.
Ms Herold named the officer killed as Eric Talley, a 51-year-old who had been with the Boulder police department since 2010.
“The heroic action of this officer when he responded to the scene… phone calls of shots fired in the area and a phone call about a possible person with a patrol rifle,” she said, adding: “Officer Talley was the first on the scene and he was fatally shot.”
Ms Herold did not provide further details about the shooting, but said that the investigation was “very complex” and would take “no less that five days to complete”.
The names of the other victims will not be released until relatives have been informed.
On Twitter, Colorado Governor Jared Polis said: “My prayers are with our fellow Coloradans in this time of sadness and grief as we learn more about the extent of the tragedy.”
President Joe Biden has been briefed about the shooting.
Last month, Mr Biden said he would be recommending tougher legislation to ensure background checks on anyone wishing to purchase a firearm.