Once sperm cells are produced in the testis and accumulate in the epididymis, they rely on the ductus (vas) deferens and ejaculatory duct to propel them into the urethra and out of the penis during ejaculation. The ejaculatory duct delivers sperm into the urethra, adding secretions and additives from the prostate necessary for sperm function, while providing an interface between the reproductive and urinary systems in men (see image below).
Ductus deferens (vas deferens)
The ductus deferens, or vas deferens, is a fibromuscular tube that is continuation of the epididymis and is an excretory duct of the testis. Each ductus is 30-45 cm in length and serves to transport sperms cells from the respective epididymis to the ipsilateral ejaculatory duct.  Extending from the globus minor, or tail of epididymis, the convoluted portion of the ductus deferens becomes straighter (diameter, 2-3 mm) as it ascends posterior to the testis and medial to the epididymis to join the other structures of the spermatic cord extending toward the inguinal canal.
As the spermatic cord is formed at the deep (internal) abdominal ring, the ductus deferens curves lateral then medial to loop over the epigastric artery. At this point, the ductus travels along the lateral pelvic wall, medial to the distal ureter, along the posterior wall of the bladder until it reaches the seminal vesicles dorsal to the prostate. The ductus deferens runs medial to the seminal vesicle and enlarges and terminates into a sacculated structure called the ampulla of the ductus. The ampulla attenuates at the base of the prostate and merges with the seminal vesicle duct to form the ejaculatory duct. 
Each ductus deferens has an artery usually derived from the superior vesicle artery (artery to the ductus), with venous drainage to the pelvic venous plexus. Lymphatic drainage of the ductus deferens is to the external and internal iliac nodes and innervation is mainly sympathetic from the pelvic plexus.
There are two ejaculatory ducts, left and right side, that are formed by the union of the duct from the seminal vesicle and the ductus (vas) deferens. Each ejaculatory duct is approximately 2 cm in length and starts at the base of the prostate, runs along the middle and lateral lobes, and terminates at the verumontanum on each respective side.  The vasculature, innervation and lymphatics of the ejaculatory ducts are the same as for the ductus deferens. The ejaculatory ducts can be divided into 3 distinct sections: proximal, middle, and distal.
Proximal ejaculatory duct
Also referred to as the seminal vesicle-ejaculatory duct junction, the proximal portion of the ejaculatory duct is formed from the union of the seminal vesicle and the ampulla of the ductus deferens in the posterior-superior area of the prostate, as shown below. Though the junction is anatomically distinct, the duct is actually an extension of the seminal vesicle, whereas the ampulla of the ductus deferens enters the tubular structure at an angle. The duct lumen is approximately 1.7 mm in diameter. 
Middle ejaculatory duct
The middle portion, or the intraprostatic ejaculatory duct, runs 10-15 mm on the posterior surface of the prostate. Each duct then angles anteriorly, enters the prostate, and extends another 5-8 mm in length.  Inside the prostate, the pair of ducts approaches each other from their respective sides and nearly meet at the end of this portion. The luminal diameter is approximately 0.6 mm. 
Distal ejaculatory duct
Once the middle portion of the duct terminates in the central zone of the prostate, the distal segments, or terminal ejaculatory duct, course together along the sides of the prostatic utricle and terminate at the seminal colliculus (verumontanum).  Here, the ducts separate again and each end with slit-like orifices adjacent to the margin of the utricle and into the proximal prostatic urethra at a downstream angle.  In this segment, the ducts diminish in size to a luminal diameter of 0.3 mm and converge toward the terminal ends. 
Histologically, the ductus deferens consists of 3 layers, the outer layer, the middle muscular layer, and the internal mucous layer. The middle or muscular layer is remarkably thick in proportion to the luminal diameter and consists mostly of outer longitudinal smooth muscle fibers with inner circular muscle fibers.  Interestingly, at the proximal most segment of the ductus deferens, the muscular layer is divided into 3 sections, an outer and inner layer of longitudinal muscle fibers with a middle layer of circular fibers. 
However, as the ductus ascends towards the inguinal canal, only 2 muscular layers are present and the innermost longitudinal muscle fibers are no longer present. This muscular layer is about 1.5 mm thick is palpable in the spermatic cord.  The mucosal layer is protective for the lumen and consists of pseudostratified columnar epithelial cells arranged in a longitudinal fashion. The lamina propria is rich in elastic fibers. The columnar cells have apical stereo cilia that help project the sperm along the tube. There is also a layer of basal cells that function primarily to replenish the columnar cells.  The lumen is about 2.5 mm in diameter. 
Proximal ejaculatory duct
Under the microscope, the ejaculatory duct consists of 3 layers that are extremely thin. An outer muscular layer, a middle layer made up of a collagenous material, and an inner mucosal layer consisting of pseudo-stratified columnar epithelium.  The muscular fibers are longitudinal and course from the seminal vesicles. Notably, the muscular layer is more prominent in the proximal portion of the ejaculatory duct relative to the rest of the duct.
Middle ejaculatory duct
After both ducts penetrate the prostate, they are surrounded by a common connective tissue sheath. By this point, the outer muscular layer that was present in the proximal portion of the duct has atrophied, leaving a thinner collagenous middle layer. In addition, the tubular diameter has also decreased relative to the proximal portion of the duct. 
Distal ejaculatory duct
Unlike the previous 2 segments, the distal duct does not have a clear outer muscular layer. Rather, there are intermittent bundles of longitudinal fibers that encase the duct. Likewise, the middle collagenous layer becomes thinner relative to the middle segment. Between the two ducts in the seminal colliculus is a longitudinal band of smooth muscle fibers, which makeup the terminal segment of the trigone muscle of the bladder. 
In some men, a nonfunctional anomaly is found associated with the ductus deferens. The vas aberrans of Haller is a long tube commencing at the tail end of the epididymis or with the ductus deferens and extends into the spermatic cord.  The tube length is variable and has been measured anywhere from 2-14 inches.  It terminates abruptly and has no effect on the male reproductive tract.
Another variant along the male reproductive tract is the organ of Giraldes, which is thought to be a remnant of the mesonephric (Wolffian) body. The organ is a collection of convoluted tubules consisting of ciliated columnar cells located in front of the globus major.  Like the aberrans of Haller, this structure is nonfunctional and does not affect the male reproductive tract.
Ejaculatory duct obstruction (EDO) is a congenital or acquired pathological condition in which the efflux of semen is not possible due to obstruction of one or both of the ejaculatory ducts.  This condition causes male infertility and typically presents with symptoms of azospermia, including failure to ejaculate and/or lower abdominal pain. EDO occurs in 1-5% of all male infertility cases.  Diagnosis of ejaculatory duct obstruction can often be performed by transrectal ultrasound.
An axial transrectal ultrasound image of normal seminal vesicles is below. The white arrows indicate the ampulla of the vas deferens.
The congenital form of EDO is typically caused by paramesonephric (Mullerian) duct cysts. Acquired forms can be linked to inflammation of the ejaculatory duct secondary extension from prostatitis, orchitis, seminal vesiculitis, and urethritis. These inflammatory diseases can be due to common urinary pathogens as well as sexually transmitted diseases like chlamydia. 
Genitourinary tuberculosis can involve the ductus deferens or ejaculatory ducts resulting in obstruction, infertility, and/or chronic pain. Historically, smallpox was also a cause of postinflammatory ejaculatory duct obstruction. Calcifications and infections can partially or totally obstruct the duct. However, in most cases, there is no history of inflammation, and the etiology of EDO remains undetermined.
The ductus deferens can also be congenitally absent. These rare cases are usually associated with cystic fibrosis. These men make normal sperm, however.  Adult men undergoing evaluation for infertility are occasionally found to have a mild, undiagnosed form of cystic fibrosis that had no other presenting symptoms. 
The course of the ductus deferens increases the risk of this structure being damaged during inguinal or lower ureteral surgery. The ductus deferens or the testicular blood supply may be injured or ligated at the time of hernia repair, hydrocelectomy, and varicocelectomy. The distal aspect of the ductus can be injured during ureteral reimplantation. Awareness of the anatomy of the ductus deferens and cautious identification during these surgical procedures is important to their preservation.
Hematospermia is typically a self-limiting, benign symptom. However, it can indicate pathology in the urinary tract or a systemic increased bleeding tendency in the patient. On rare occasion hematospermia may indicate inflammatory processes or other systemic diseases involving the ductus deferens.
Bilateral calcification of the ductus deferens is seen in patients with diabetes. Tuberculosis, syphilis, gonorrhea, schistosomiasis, and chronic urinary tract infection can also cause ductus deferens calcification but with these etiologies, calcifications are more frequently irregular and unilateral.