You have set yourselves up for a mess with the Landlord already.
You should have made the landlord aware that you would be looking to purchase a house PRIOR to actually purchasing it.
You need the give the landlord notice that you will be moving.
You can be held liable for each month's rent until July - if the apartment goes unrented. You can be held liable for all costs related to re-renting the apartment such as, but not limited to advertising.
If the landlord ends up having to rent the apartment for a LOWER rent than your current lease amount, you can be held liable for the DIFFERENCE for each month until July.
Your best bet is to sit down with the landlord and negotiate. Keep in mind that the LL will be doing YOU a FAVOR in negotiating at all.
It is not unheard of for tenants to offer a cash settlement to break the lease.