Fitted from the factory, they are legal, but they must have auto-levellers and washers.
Most cars without factory HIDs don't have auto-levellers, and a lot don't have washers either, so technically a lot of people are driving with illegal lights.
You can (and I have done) pass the MOT for having aftermarket HIDs as long as the light they give out is only yellow or white. If they are blue then they will fail the MOT, just like blue sidelights. For this reason the majority of people seem to go with 600k HIDs, myself included. This gives a pure white light with just a slight tinge of blue. 8000k is more noticeably blue and may be pushing the boundaries with MOT, although I do know people who have had these and passed the MOT this way. Any higher than 8000k HIDs (10000k for example) will most likely fail the MOT, and also give out much poorer light output.
So although most people are driving with HIDs illegally, you can pass an MOT with them, and only very fussy police may ask you to get rid of them - I don't know of anyone yet who has been pulled over by the Police for them.