Does nitric oxide effect erections?

as far as my knowledge goes, nitric oxide dilates blood vessels but also relaxes the vessels that are supposed to close to achieve an erection therefore working against it.