Sam's supernatural abilities are the result of him being fed Azazel's demon blood while he was an infant. Sam exhibits signs of precognition throughout the first season, manifesting as dreams of others' deaths and later as visions.
Sam had to drink demon blood because he needed a lot of strength to keep Lucifer under his control. But still, that didn't work. In the end, his love for his brother gave him the strength to overpower Lucifer; and in doing so, he also took Michael along with him into the cage.