Dobby’s death occurred moments after he helped Harry, Ron, Hermione, Luna, Ollivander and Griphook escape Malfoy Manor.
The stab wound was fatal, but not before Dobby was able to utter two final words: “Harry Potter.”
As J.K. Rowling notes in her Tweet, Dobby didn’t actually die at the Battle of Hogwarts.
Upon whisking Harry and Griphook away from the Manor and off to the safety of Shell Cottage, Dobby was struck by a dagger thrown by Bellatrix Lestrange seconds before he disapparated.