Tadalafil works by inhibiting the enzyme phosphodiesterase type 5 (PDE5), which is responsible for the degradation of cyclic guanosine monophosphate (cGMP) in the corpus cavernosum of the penis. By inhibiting PDE5, tadalafil helps to increase the levels of cGMP, leading to smooth muscle relaxation and increased blood flow to the penis, which facilitates an erection during sexual stimulation.