Whenever you win a battle, you gain leadership xp. The amount is displayed at the end of battle in the report that shows kills, etc.
The more enemies you (or your troops) kill, the more leadership XP you obtain.
This means that when you're fighting alongside friends or other people, they may also take away kills from your battle and reduce your leadership XP.