Molecular modeling studies were carried out on a set of piperazine and 3,8-diazabicyclo[3.2.1]octane derivatives with the aim to highlight the main factors modulating their affinity for the mu-opioid receptor. Structure-affinity relationships were developed with the aid of molecular mechanics and semiempirical quantum-mechanics methods. According to our proposed pharmacodynamic model, the binding to the mu-receptor is promoted by the following physico-chemical features: the presence of hydrocarbon fragments on the nitrogen ring frame capable of interacting with one of two hypothesized hydrophobic receptor pockets; a 'correct' orientation of an N-propionyl side chain so as to avoid a sterically hindered region of the receptor; the possibility of accepting a hydrogen bond from a receptor site complementary to the morphine phenol oxygen.