Naruto talked Nagato into believing in him and his ideas about peace. Nagato then used his Rinne Rebirth jutsu to sacrifice himself, while reviving everyone who died during his invasion of the Leaf.
Kakashi did die during the invasion (along with Fukasaku, Shizune, Ebisu, Choza, & many other ninja). He had a conversation with his dad, Sakumo (aka, the Leaf's White Fang) around a campfire, telling him that he approved of his choice to save his friends over completing his mission. Sakumo joined his wife in the afterlife (she died when Kakashi was very young) and Kakashi came back to life as a result of Nagato's sacrifice.
OP: you must have skipped several episodes to not know about all of this. If so, I suggest you go back and watch them. The Invasion of Pain arc is fantastic!