Somali security forces killed three militants holed up in a building in the capital Mogadishu on Friday and the battle for the area was now over, police officials said.