The attack in Tripoli took place as election officials were registering voters for polls scheduled later this year.