It is not at all illegal to give a bad reference, but as builders mate quite rightly says, what is said must be true.
ipa if you were late for work 4 days out of 5, and took 5 sickies a month and shouted at people so much that 3 of your colleagues complained then, yes, your previous employer might give you a bad, but perfectly true reference.
But of course Im sure you arent like that at all! The fact that you think some of what was said was untrue means that someone must have told you the contents of the conversation - who was this? As buildersmate says, your best bet is to put an alternative explanation forward to your 'new' employer in as nice a manner as possible.