Willow lead the scooby gang to buffy's grave with some magic potions made from deers blood and with a rare one of a kind vase, she called up on the gods to bring her back from the dead.
Some demons knowing that Sunnydale was missing a slayer came to take controll and interupted the spell half way through, the scooby gang retreated thinking that the spell didnt work but actually it did and to add to that, they left her burried under ground so she had to dig her way out.