JK Rowling has apologised for killing off fan favourite Remus Lupin as she marked the 18th anniversary of the Battle of Hogwarts.

The Harry Potter author, who tweets an apology annually on May 2, said she "didn't enjoy doing it" as she revealed that she never intended to kill off the beloved Marauder, former Defence Against The Dark Arts teacher and Order of the Phoenix member.

Read more: JK Rowling reveals her favourite Harry Potter character and it's caused a lot of controversy

She wrote: "Once again, it's the anniversary of the Battle of Hogwarts so, as promised, I shall apologise for a death. This year: Remus Lupin."

She has previously admitted that she planned for Arthur Weasley - Ron's father - to die in the final battle but he was given a reprieve in the place of Lupin and his wife Nymphadora "Tonks".

Read more: The Next JK Rowling? Step forward Glaswegian fantasy writer Martin Stewart

Atoning for her sins on Twitter, Rowling revealed she only changed her mind at the writing of the fifth book.

She tweeted: "In the interests of total honesty I'd also like to confess that I didn't decide to kill Lupin until I wrote Order of the Phoenix."

Read more: New Harry Potter book to be released in July​

Lupin, played in the films by David Thewlis, was murdered in the battle by Death Eater Antonin Dolohov while Tonks was killed by Bellatrix Lestrange, leaving their baby son Teddy an orphan.

She continued: "Arthur lived, so Lupin had to die. I'm sorry. I didn't enjoy doing it.

The only time my editor ever saw me cry was over the fate of Teddy." Lupin's death is still a sore subject for fans, who fell in love with the werewolf, nicknamed Moony, who was known as one of the Marauders at Hogwarts alongside James Potter, Sirius Black and Peter Pettigrew.

Rowling told one fan who tweeted that Lupin "is and always will be my favourite character in the Harry Potter universe" that it was "the best tribute he could have".

Last year she apologised for the death of Fred Weasley.

Fifty thousand fans retweeted her post, which read: "Today I would just like to say: I'm really sorry about Fred. *Bows head in acceptance of your reasonable ire*"