THC, or tetrahydrocannabinol, is the chemical responsible for most of marijuana's psychological effects. THC changes behavior by binding — fitting together like a lock and key — to receptors on nerve cells, which then respond with a change in activity.
More information on THC here.