The mechanisms by which testosterone plays a role in erectile function are not completely understood. A study evaluating the effect of testosterone on erections in surgically castrated rabbits and control animals, in which the rabbits’ intracavernosal pressures were compared after cavernosal nerve stimulation, determined that castrated rabbits had much lower pressures after stimulation than control rabbits did.  Notably, the pressures increased when castrated rabbits received exogenous testosterone replacement.
Vacuum devices for ED, also called pumps, offer an alternative to medication. The penis is placed inside a cylinder. A pump draws air out of the cylinder, creating a partial vacuum around the penis. This causes it to fill with blood, leading to an erection. An elastic band worn around the base of the penis maintains the erection during intercourse.
In males, testosterone is synthesized primarily in Leydig cells. The number of Leydig cells in turn is regulated by luteinizing hormone (LH) and follicle-stimulating hormone (FSH). In addition, the amount of testosterone produced by existing Leydig cells is under the control of LH, which regulates the expression of 17β-hydroxysteroid dehydrogenase.
However, testosterone is only one of many factors that aid in adequate erections. Research is inconclusive regarding the role of testosterone replacement in the treatment of erectile dysfunction. In a review of studies that looked at the benefit of testosterone in men with erection difficulties, nearly half showed no improvement with testosterone treatment. Many times, other health problems play a role in erectile difficulties. These can include:
early 15c., "physical weakness," also "poverty," from Middle French impotence "weakness," from Latin impotentia "lack of control or power," from impotentem (nominative impotens); see impotent. In reference to a want of (male) sexual potency, from c.1500. The figurative senses of the word in Latin were "violence, fury, unbridled passion." Related: Impotency.
Before assessing the evidence of testosterone’s action in the aging male it is important to note certain methodological considerations which are common to the interpretation of any clinical trial of testosterone replacement. Many interventional trials of the effects of testosterone on human health and disease have been conducted. There is considerable heterogenicity in terms of study design and these differences have a potential to significantly affect the results seen in various studies. Gonadal status at baseline and the testosterone level produced by testosterone treatment in the study are of particular importance because the effects of altering testosterone from subphysiological to physiological levels may be different from those of altering physiological levels to supraphysiological. Another important factor is the length of treatment. Randomised controlled trials of testosterone have ranged from one to thirty-six months in duration (Isidori et al 2005) although some uncontrolled studies have lasted up to 42 months. Many effects of testosterone are thought to fully develop in the first few months of treatment but effects on bone, for example, have been shown to continue over two years or more (Snyder et al 2000; Wang, Cunningham et al 2004).
^ Jump up to: a b Sapienza P, Zingales L, Maestripieri D (September 2009). "Gender differences in financial risk aversion and career choices are affected by testosterone". Proceedings of the National Academy of Sciences of the United States of America. 106 (36): 15268–73. Bibcode:2009PNAS..10615268S. doi:10.1073/pnas.0907352106. PMC 2741240. PMID 19706398.
Exercise and lifestyle modifications may improve erectile function. Weight loss may help by decreasing inflammation, increasing testosterone, and improving self-esteem. Patients should be educated to increase activity, reduce weight, and stop smoking, as these efforts can improve or restore erectile function in men without comorbidities. Precise glycemic control in diabetic patients and pharmacologic treatment of hypertension may be important in preventing or reducing sexual dysfunction. 
Erectile dysfunction or ED (It used to be called impotence) is the inability to achieve or sustain an erection suitable for sexual intercourse. Problems with erections may stem from medications, chronic illnesses, poor blood flow to the penis, drinking too much alcohol, or being too tired. Erectile dysfunction can occur at any age, but it is more common in men older than 75.
It appears that testosterone has NOS-independent pathways as well. In one study, castrated rats were implanted with testosterone pellets and then divided into a group that received an NOS inhibitor (L-nitro-L-arginine methyl ester [L-NAME]) and a control group that received no enzyme.  The castrated rats that were given testosterone pellets and L-NAME still had partial erections, a result suggesting the presence of a pathway independent of NOS activity.
Testosterone is the primary male sex hormone and an anabolic steroid. In male humans, testosterone plays a key role in the development of male reproductive tissues such as testes and prostate, as well as promoting secondary sexual characteristics such as increased muscle and bone mass, and the growth of body hair. In addition, testosterone is involved in health and well-being, and the prevention of osteoporosis. Insufficient levels of testosterone in men may lead to abnormalities including frailty and bone loss.
Penile erection is managed by two mechanisms: the reflex erection, which is achieved by directly touching the penile shaft, and the psychogenic erection, which is achieved by erotic or emotional stimuli. The former uses the peripheral nerves and the lower parts of the spinal cord, whereas the latter uses the limbic system of the brain. In both cases, an intact neural system is required for a successful and complete erection. Stimulation of the penile shaft by the nervous system leads to the secretion of nitric oxide (NO), which causes the relaxation of smooth muscles of corpora cavernosa (the main erectile tissue of penis), and subsequently penile erection. Additionally, adequate levels of testosterone (produced by the testes) and an intact pituitary gland are required for the development of a healthy erectile system. As can be understood from the mechanisms of a normal erection, impotence may develop due to hormonal deficiency, disorders of the neural system, lack of adequate penile blood supply or psychological problems. Spinal cord injury causes sexual dysfunction including ED. Restriction of blood flow can arise from impaired endothelial function due to the usual causes associated with coronary artery disease, but can also be caused by prolonged exposure to bright light.
One of the first steps is to distinguish between physiological and psychological ED. Determining whether involuntary erections are present is important in eliminating the possibility of psychogenic causes for ED. Obtaining full erections occasionally, such as nocturnal penile tumescence when asleep (that is, when the mind and psychological issues, if any, are less present), tends to suggest that the physical structures are functionally working. Similarly, performance with manual stimulation, as well as any performance anxiety or acute situational ED, may indicate a psychogenic component to ED.
Attention, memory, and spatial ability are key cognitive functions affected by testosterone in humans. Preliminary evidence suggests that low testosterone levels may be a risk factor for cognitive decline and possibly for dementia of the Alzheimer's type, a key argument in life extension medicine for the use of testosterone in anti-aging therapies. Much of the literature, however, suggests a curvilinear or even quadratic relationship between spatial performance and circulating testosterone, where both hypo- and hypersecretion (deficient- and excessive-secretion) of circulating androgens have negative effects on cognition.
Transdermal preparations of testosterone utilize the fact that the skin readily absorbs steroid hormones. Initial transdermal preparations took the form of scrotal patches with testosterone loaded on to a membranous patch. Absorption from the scrotal skin was particularly good and physiological levels of testosterone with diurnal variation were reliably attained. The scrotal patches are now rarely used because they require regular shaving or clipping of scrotal hair and because they produce rather high levels of dihydrotestosterone compared to testosterone (Behre et al 1999). Subsequently, non-scrotal patches were developed but the absorptive capacity of non-scrotal skin is much lower, so these patches contain additional chemicals which enhance absorption. The non-scrotal skin patches produce physiological testosterone levels without supraphysiological dihydrotestosterone levels. Unfortunately, the patches produce a high rate of local skin reactions often leading to discontinuation (Parker and Armitage 1999). In the last few years, transdermal testosterone gel preparations have become available. These require daily application by patients and produce steady state physiological testosterone levels within a few days in most patients (Swerdloff et al 2000; Steidle et al 2003). The advantages compared with testosterone patches include invisibility, reduced skin irritation and the ability to adjust dosage, but concerns about transfer to women and children on close skin contact necessitate showering after application or coverage with clothes.