They come in two forms: the first are psionic illusory duplicates of other beings/vehicles, courtesy of psionic power. This psionic ability to create hallucinations can be used by high templar though the dark templar are able to employ a similar technique on their ships. These phantasms are without physical substance.
The second version is technological, and is used by sentries.
The high templar selects a unit, creating two duplicates of it. Hallucinations appear with a blue tint to the creating and controlling player, while all other players will see them as duplicates of the original. Hallucinations do not inflict damage when they "attack", may not cast spells, or produce units (important for hallucinated carriers and reavers), and take double damage from all attacks. Hallucinations last for a limited time and automatically disappear when hit by spells (eg. EMP shockwave, Mind Control).