He was killed by Severus Snape, because Draco Malfoy was chosen to finish Dumbledore, but couldn't go through with it. Snape made an unbreakable vow to finish the task if Draco couldn't, which ends with Dumbledore being killed.
Albus Dumbledore was dying from a curse caused by the ring horcrux. He arranged to have Snape kill him when the time came to protect Draco's soul, to save himself undo suffering caused by the sadistic Greyback or Bellatrrix. He also wanted to keep Snape in Voldemort's good graces so that Snape could try to protect the students of Hogwarts.