Police officers had earlier stopped the saloon car at traffic lights and were taking the occupants for questioning when the bomb exploded, the ministry said.
Kenya's security forces are struggling to contain a surge in bomb and gun attacks that the authorities blame on the Somali Islamist militants who killed at least 67 people when they laid siege to Nairobi's Westgate shopping mall in September.
(READ MORE: Trial of Kenya Westgate mall attack suspects begins)
Kenyans are increasingly alarmed at the relative ease at which the militants and radicalised youths are able to carry out deadly strikes in the heart of Kenya, east Africa's biggest economy. It was not immediately clear who was behind the attack.
"At least 4 people dead after a saloon exploded at Pangani police station. Two of them are police officers,” the ministry said.
Pangani is located next to Nairobi's Eastleigh district, an area populated by Somalis and targeted in past bomb and grenade attacks.
A second controlled detonation was carried out by bomb disposal officers shortly after the initial blast, a Reuters witness said.
Kenyan President Uhuru Kenyatta last month said the vital tourism industry was "on its knees" after attacks by al Qaeda-linked Islamist insurgents carried out in retaliation for the country's troop deployment in neighbouring Somalia.
(READ MORE: Five killed in blast in Kenyan capital Nairobi: emergency services)
It is common for Kenyan police to demand a ride back to police stations in vehicles they have stopped. But some Kenyan and African Twitter expressed consternation that they should get into a suspicious car at a time of heightened insecurity.
"Crazy & unfortunate that #Kenya police officers would board a "suspicious" car. Not good protocol," one Twitter user wrote.