Writing critically about previous work I'm at the stage of my PhD where I'm beginning to write my thesis. 

At the beginning of my PhD, my supervisor asked me to go back and repeat some work done by the student who had the project before me. This was meant to be a 'breaking in gently' exercise, but ended up taking over 18 months because of missing data and incorrect conclusions necessitating things to essentially be redeveloped from scratch. I think in fairness there was a certain degree of naivety on the part of my supervisor not realising how long things take - he's quite hands off, especially in recent years as he got elected to become head of the school. 

That said, this situation has caused a fair deal of conflict over the last 4 years. My supervisor resents the fact that I spent so much time not 'getting anywhere', and I resent wasting a large proportion of my funding not really doing anything useful (the previous work has been published, and my new contributions don't deviate so significantly to warrant an additional publication). The whole situation is compounded by the fact that the student in question was the 'golden girl' of the lab, so any criticism of her work falls on deaf ears (its something of an  in-joke within the group, as the girl in question is generally understood not to be terribly great in the lab). 

I recently gave a draft of a few chapters to my supervisor, and without reading them fully he immediately asked them to be re-written to avoid any criticism of the previous work, citing me as the issue, rather than the previous work (multiple people have verified the mistakes with the previous work). 

I'm unsure of what to do, and would welcome some advice. I don't really need my supervisor at this point as I already have a job and don't need his permission to submit, but at the same time would like to ameliorate the issue to reach some kind of compromise.  Equally, I don't want to yield to his will, as after wasting 18 months fixing the previous work, I want to tell the story. 

To clarify, and as I can't comment - my supervisor wants me to ignore the entire 18 months of work. For obvious reasons this is undesirable.
Every published work has at least a few sentences that criticize previous published work or a collection of them. They are often constructive, in the sense that they generally point limitations and how to build upon them, in sentences that are similar to Dawn's comments. 

Now, I have no idea what kind of criticism you made, but a common pitfall for junior academics (and I am one myself) is to end up over-generalizing a claim, both when discussing their own results and when criticizing other's work. The other student may have fallen into the former trap, by over-generalizing their result (you said they presented incorrect conclusions). But you may be falling into the latter trap by being overly critical and, maybe, not having sufficient data to back up your claims that the other student's conclusion is wrong. Your advisor may have detected it by simply glancing over your text, which is easy with enough experience. 

In general, I advise people to be very cautious of what they are criticizing, especially if it is not a limitation of the other study, but something they got wrong. It is often a better idea to talk to the other person before openly criticizing them. The other person is likely to know their work much better than you do. If you manuscript falls into their hands for review (which probably won't be your case, but still), and you are wrong, it's a strong argument for rejecting it.

Now, if you still feel that you are right, that you are not over-generalizing, that you have sufficient data to back up your claim, that it would be relevant to include it in your thesis, then ask your advisor. Explain how this criticism would be important to your thesis (or paper in preparation), and ask how you should include it without being overly critical.

If it is not relevant to your work, it would be weird to see an unrelated note/section discussing how someone else's unrelated work is incorrect, even if you spent 18 months on it (which is a lot of time, and certainly unfortunate, but these things happen, and you should talk to your advisor and other people about how to avoid spending large amounts of time without progress).