The militants have carried out several attacks in the region in recent weeks after they were driven out of their strongholds in central and southern Somalia by African Union troops and the Somali army.
Abshir Mohamed, a policeman in charge of security at the deputy police commander Muhidin Ahmed's home, said the rebels drove up to a checkpoint near the house in a minibus late on Saturday.
"They opened fire and hurled grenades at us once when we stopped the car to check," Mohamed said.
Two policemen were killed and five others injured, he said, adding that one militant was also killed.
Al Shabaab, which analysts say might have moved extra fighters to the northern region of Puntland, claimed responsibility for the attack.