Fellow officers and paramedics treated the officer at the scene, according to a police statement. However, he later died of his injuries at the hospital.
A 23-year-old man was detained at the scene, police said. He is in hospital in a critical condition from a gunshot wound.
The Metropolitan Police Service has launched a murder investigation.
The fatal shooting of a police officer is a rare event in the United Kingdom, where police do not routinely carry guns.
No police firearms were discharged during the incident, the police statement said.
“This is a truly shocking incident in which one of our colleagues has lost his life in the most tragic circumstances. My heart goes out to his family, direct colleagues and friends,” Metropolitan Police Commissioner Cressida Dick said.
UK Home Secretary Priti Patel said the fatal shooting of a police officer was a “sad day for our country” and a “terrible reminder” of the risks police officers face.
“I am deeply shocked and saddened to learn that a Metropolitan Police Officer has been shot and killed in the line of duty,” she said in a statement. “My thoughts today are with his family, friends, and policing colleagues in London and across the country.
Patel said she had offered her condolences to Dick and offered whatever support was needed as the shooting was investigated.
“This is a sad day for our country and another terrible reminder of how our police officers put themselves in danger each and every day to keep the rest of us safe,” she said.