Ketoconazole is very lipophilic, which leads to accumulation in fatty tissues. The less toxic and more effective triazole compounds fluconazole and itraconazole are sometimes preferred for internal use. Ketoconazole is best absorbed at highly acidic levels, so antacids or other causes of decreased stomach acid levels will lower the drug's absorption when taken orally. Absorption can be increased by taking it with an acidic beverage, such as cola.
The side effects of ketoconazole are sometimes used to treat nonfungal problems. The decrease in testosterone caused by the drug makes it useful for treating prostate cancer and for preventing postoperative erections following penile surgery. Another use is the suppression of glucocorticoid synthesis, where it is used in the treatment of Cushing's syndrome. These side effects have also been studied for use in reducing depressive symptoms  and drug addiction; however, it has not succeeded in either of these roles.
Ketoconazole is also used in combination with other drugs such as zinc pyrithione in rinse-off products. The antidandruff shampoo is designed for people who have a more serious case of dandruff where symptoms include, but are not limited to constant, nonstop flaking, and severe itchiness.
It is a pregnancy category C drug because animal testing has shown it to cause teratogenesis in high dosages. Recently, two human test cases (both during the treatment of Cushing's syndrome) were reported to have no adverse effects, but this small sample precludes drawing any meaningful conclusions. A subsequent trial in Europe failed to show a risk to infants of mothers receiving ketoconazole.
Preliminary research suggests ketoconazole shampoo may be beneficial in men suffering from androgenic alopecia. Support for this comes from a study in 1998 that compared ketoconazole 2% to the proven hair loss drug minoxidil 2% in men with androgenic alopecia. In a sample of 27 men, "[h]air density and size and proportion of anagen follicles were improved almost similarly by both ketoconazole and minoxidil regimens." The men washed with ketoconazole 2% shampoo once every two to four days, leaving the shampoo on the scalp for three to five minutes before rinsing (as with the treatment of dandruff and seborrheic dermatitis). While ketoconazole's mechanism of action in hair loss is still unclear, the researchers in the 1998 study postulated both hormones and the immune system may act synergistically to cause injury to the hair follicle. Since ketoconazole effectively treats the Malassezia fungus that commonly inhabits the scalp, the researchers hypothesized it may prevent hair loss by reducing inflammation from the fungus, in addition to having a direct anti-inflammatory effect. The researchers were guarded about the meaning of their results, saying more rigorous studies on larger groups of men should be done to confirm the findings, both to evaluate the ideal dosage and formulation, and to assess the desirability of routine treatment in this condition.
In 2002, a study of 150 men at the University of Liège in Belgium found 1% ketoconazole shampoo used 2-3 times a week for six months increased hair shaft diameter by 5.4%, increased anagen hair by 4.9%, and decreased hair shedding by 17.3%, although it found no effect on hair density. An additional 2002 study in men with androgenetic alopecia found that a regimen of ketoconazole and finasteride was more effective than finasteride alone in treating male pattern baldness. In 2005, a study of ketoconazole in mice also found support the existence of a stimulatory effect on hair growth.
Although ketoconazole may be useful as a hair loss treatment, the shampoo is currently only FDA-approved for the treatment of dandruff and seborrheic dermatitis of the scalp.
As an antiandrogen, ketoconazole operates through at least two mechanisms of action. First, and most notably, high oral doses of ketoconazole (e.g. 400 mg three times per day) block both testicular and adrenal androgen biosynthesis, leading to a reduction in circulating testosterone levels. It produces this effect through inhibition of cytochrome P450 and 17,20-lyase, which are involved in the synthesis and degradation of steroids, including the precursors of testosterone. Due to its efficacy at reducing systemic androgen levels, ketoconazole has been used as a treatment for androgen-dependent prostate cancer. Second, ketoconazole is an androgen receptorantagonist, competing with androgens such as testosterone and DHT for androgen receptor binding. This effect is thought to be quite weak, even with high oral doses of ketoconazole.
Ketoconazole inhibits growth of dermatophytes and yeast species such as Candida albicans. The rise in the number of HIV/AIDS immunocompromised patients has led to an increase in the frequency and significance of opportunistic fungal infections. Resistance to ketoconazole has been observed in a number of clinical fungal isolates, including C. albicans. Experimentally, resistance usually arises as a result of mutations in the sterol biosynthesis pathway. Defects in the sterol 5-6 desaturase enzyme reduce the toxic effects of azole inhibition of the 14-alpha demethylation step. Multidrug-resistance (MDR) genes can also play a role in reducing cellular levels of the drug. As azole antifungals all act at the same point in the sterol pathway, resistant isolates are normally cross-resistant to all members of the azole family.
The first racemic synthesis of ketoconazole was published in 1979. In this synthesis, cis- and trans-isomers were separated by crystallization because only the two cis-enantiomers are used in the commercially available drug. 
Synthesis of ketoconazole (8)
The synthesis was started with dichloroacetophenone (1) and glycerine. The ketal was directly brominated to yield alcohol 2. This was further transformed into the corresponding benoylic ester 3 and at this stage cis- and trans-isomers were separated. The imidazole residue was then introduced followed by a basic hydrolysis of the ester moiety. The free hydroxyl group of 5 was converted into the mesylate and was then replaced by substituent 7 to yield ketoconazole 8 in six steps and an overall yield of 12%.
^Loli, P; Berselli ME, Tagliaferri M (December 1986). "Use of ketoconazole in the treatment of Cushing's syndrome". The Journal of Clinical Endocrinology and Metabolism63 (6): 1365–71. doi:10.1210/jcem-63-6-1365. PMID3023421.
^Malison, RT; Anand A, Pelton GH, Kirwin P, Carpenter L, McDougle CJ, Heninger GR, Price LH (October 1999). "Limited efficacy of ketoconazole in treatment-refractory major depression". Journal of Clinical Psychopharmacology19 (5): 466–70. doi:10.1097/00004714-199910000-00011. PMID10505589.
^Ward, AS; Collins ED, Haney M, Foltin RW, Fischman MW (November 1998). "Ketoconazole attenuates the cortisol response but not the subjective effects of smoked cocaine in humans". Behavioural Pharmacology9 (7): 577–86. doi:10.1097/00008877-199811000-00013. PMID9862083.
^Berwaerts, Joris; Johan Verhelst, Charles Mahler and Roger Abs (June 1999). "Cushing's syndrome in pregnancy treated by ketoconazole: case report and review of the literature". Gynecological Endocrinology13 (3): 175–82. doi:10.3109/09513599909167552. PMID10451809.
^Heeres, J.; Backx, L. J. J.; Mostmans, J. H.; Van Cutsem, J. (1979). "Antimycotic imidazoles. Part 4. Synthesis and antifungal activity of ketoconazole, a new potent orally active broad-spectrum antifungal agent". Journal of Medicinal Chemistry22 (8): 1003–5. doi:10.1021/jm00194a023. PMID490531.
^Heeres, J.; Backx, L. J. J.; Mostmans, J. H.; Van Cutsem, J. (1 August 1979). "Antimycotic imidazoles. Part 4. Synthesis and antifungal activity of ketoconazole, a new potent orally active broad-spectrum antifungal agent". Journal of Medicinal Chemistry22 (8): 1003–1005. doi:10.1021/jm00194a023.