The invention provides novel compounds of formula I: that are opioid receptor ligands. The invention also provides pharmaceutical compositions comprising such compounds as well as methods for treating diseases associated with opioid receptor function by administering such compounds to a mammal in need of treatment. Compounds of the invention are useful to modulate (e.g. agonize or antagonize) opioid receptor function.