PARIS — Swapping places with a woman being held hostage, the French police officer entered the supermarket where a gunman, claiming allegiance to the Islamic State, had already shot and killed two people on Friday.

While he did not carry a gun as he went inside, Lt. Col. Arnaud Beltrame did bring in his phone, which he left on a table with the line open so that his colleagues outside could listen in, according to Gérard Collomb, France’s interior minister.

The officer spent about two hours inside the Super U market facing the gunman, Radouane Lakdim, a 25-year-old French citizen born in Morocco, officials said.

After officers heard more gunshots through the phone, they rushed into the market and killed Mr. Lakdim. Colonel Beltrame, 44, who had been “seriously wounded” by gunfire, Mr. Collomb said, died overnight of his injuries.