Compounds which modulate the CB2 receptor are disclosed. Compounds according to the invention bind to and are agonists of the CB2 receptor, and are useful for treating inflammation. Those compounds which are agonists are additionally useful for treating pain.