Units get experience for destroying enemy units. Accumulating enough XP can increase the unit's rank. Each rank is attained by the unit destroying its worth of metal of enemies. This is split equally between doing the damage, and dealing the finishing blow, ie. bringing an enemy unit of the same cost down from full to 1 health is worth half a rank, and getting the last blow another half.
Experience gain can get modified. EMP damage is scaled to 10% and then the inverse of the target health - for example, a unit on 1/4 health will give 40% of the normal value. Disarm and slow damage don't give XP. Mixed damage gives XP for the real damage part. Overkill damage and EMP that doesn't add further stun time is discarded - only the actual damage done counts.
Ranks can enable morphing for certain units. After morph, the rank is rescaled by its new cost, eg. if the unit is rank 6, but then morphs to a unit 3x as expensive, it will now be rank 2. Currently all morphs that require XP require rank 3, ie. making the base unit's cost 3 times. Provided that your unit is experienced enough, it can morph again right away. For example, a Warrior costs 220, so it needs to kill 660 metal worth of enemies to be able to morph to Zeus: if a Glaive destroyed 660m worth of enemies, it will be able to morph to Zeus right away after morphing to Warrior.
The cost of morph is the difference between the target unit's cost and the morpher's cost; it's free if target is cheaper. The morph times are given in the techtree in seconds.
Here's the morph techtree (green is XP-free morphs, red is XP-enabled (rank 3)):For the legacy XP system (before v126.96.36.199), see this post.