I can't be sure about this, but if you think about it from the point of view of the tenant he signed an agreement which gave him exclusive occupation of the property for 6 months. Fair enough, he moved out and didn't tell the landlord when he should have done BUT the landlord then breached the agreement by moving someone else in and taking rent from them before the 6 months was up. Consequently, the property would not have been available for the tenant to occupy. Why should he be expected to pay rent for that period - after all he might have decided he wanted to move back in & wouldn't have been able to.
I think the landlord is either unclear himself, or is trying it on.
Of course, your friend must pay for the period up to the date the new tenants moved in. The best solution would be for him to work out on this basis how much he owes over and above the amount of the deposit and send that amount to the landlord with a clear written statement of how he has calculated the amount (& saying why - i.e. the reasons given above) and asking for the deposit to be used to cover the rest. Keep a copy in case the landlord does take further action.