Police said the incident occurred at about 2.15 a.m while the man was being detained at the Croydon Custody Centre where arrested suspects are processed.
The unnamed male officer was treated at the scene and taken to hospital where he died.
A 23-year-old man was detained at the scene of the shooting and was taken to hospital having also suffered a gunshot wound. He is in a critical condition.
Officers did not open fire and Metropolitan Police Commissioner Cressida Dick said early indications showed the suspect shot himself. A murder investigation is underway, she said.
British Prime Minister Boris Johnson, interior minister Priti Patel and Mayor of London Sadiq Khan were among the senior politicians to send their condolences to the the officer's family and colleagues.
The shooting of officers is very rare in Britain where the vast majority of police remain routinely unarmed.