The characters - played by Tom Watt and Linda Davidson - will head back to Albert Square in the new year to pay their last respects after Dr Legg loses his battle with pancreatic cancer.
Dr Legg (Leonard Fenton) returned to the BBC soap earlier this year and broke the devastating news to his friend Dot Branning (June Brown) that he had terminal cancer.
After turning down life-prolonging treatment, it was only a matter of time until his health deteriorated.
When he dies it is not only the current residents of Albert Square who want to say farewell. Three decades since they were last seen, Watt and Davidson will reprise their roles as George "Lofty" Holloway and Mary "The Punk" Smith.
The pair will guest star in one episode.
Watt, who last appeared in the soap in April 1988, said: "I was delighted John Yorke (EastEnders executive consultant) asked me if I would return to EastEnders for Dr Legg's funeral.
"Dr Legg is an iconic character so it feels fitting that Lofty should return to say goodbye. I have nothing but good memories from my time on EastEnders so it will be lovely to set foot back in Albert Square all these years later."
Davidson, whose character left in May 1988, said: "EastEnders was my first proper family. It gave me stability and a fantastic foundation from which to build an incredible life.
"The people of EastEnders have been a consistent thread throughout the intervening years. I am so thrilled, and very proud to be returning to that family 35 years later. It's going to be a blast!"
Mr Yorke said he was delighted to have the actors back for "these small but incredibly important roles".
"As soon as Leonard Fenton agreed to return as Dr Legg, it seemed just the best possible tribute we could pay both his character and the show," he said.
"Mary and Lofty are huge, iconic characters, and a central part of the show's DNA. Though both have moved on to hugely successful careers elsewhere, we are both thrilled and touched to have them back for one very special episode."
Dr Legg's funeral will air next year.