Federal agencies say Iran was trying “to stoke discord and undermine confidence in our democratic institutions”.