The only significant supernatural element in Hamlet is the ghost of Hamlet's father. Having said this, the ghost has a major part in the play, both thematically and in terms of the plot. Hamlet is a revenge tragedy, and it is the ghost who confirms Hamlet's suspicion that he has a murder to avenge and who spurs him on to kill Claudius. Hamlet worries about both the authenticity and the motives of the ghost. While it is present, he appears to be persuaded, but later he begins to doubt and consequently, to vacillate.
Macbeth also vacillates about whether to commit a supernaturally-inspired murder. Whereas Hamlet's killing of Claudius is generally regarded as being morally justified, Macbeth himself admits that his own ambition is his only reason for killing Duncan. Unlike King Hamlet's ghost, the three witches are obviously malevolent. Banquo appreciates this and treats them with contempt, even as he asks them to foretell his future. However, Macbeth comes to rely on the witches and returns to ask them to advise him further after the appearance of Banquo's ghost at the feast.
Macbeth contains more supernatural elements than Hamlet, including not only the witches and Banquo's ghost, but Hecate herself and the apparition of the airborne dagger. While the ghost of Hamlet's father has a fairly straightforward and honorable purpose, the witches and Hecate clearly want to destroy Macbeth, while the ghost of Banquo seeks to punish and expose him. Hamlet dies in the knowledge that he has avenged his father, while Macbeth realizes just before his death just how thoroughly the "juggling fiends" have tricked him.