The 19-year-old made just two first team appearances after joining the Hammers from Halmstad last summer.
He will now join Malaga, who have been relegated to the Spanish Segunda for the 2018/19 campaign.
Haksabanovic, who represented Sweden at youth level, has one senior International cap for Montenegro.
Need a VPN? Or seeking to switch? Then support Tribal Football by clicking here to sign up with our official partners NordVPN. Not only will you receive the best VPN experience, but also great discounts by signing up via Tribal Football. Thanks for your support!