If you can’t surpass your opponent’s strength, you’ll suffer a defeat. You’ll also lose units, but as long as you meet 2% of the defenders strength or have 1 Million or more attack strength in a certain category, you will be doing damage to his units. Of course you won’t gain any resources, switch the position with the defender or take over the attacked habitat, but you will still get some XP for every unit of your opponent that your army killed.