Redemption and second chances have long been superhero movie staples, and today it looks like life has imitated art. Deadline has learned that Disney has reinstated James Gunn as the writer-director of “Guardians of the Galaxy 3,” and confirmed it with Marvel and Gunn’s camp.

The decision to rehire Gunn — he was fired last July by Disney after alt-right journalists made public a fusillade of decade-old social media missives that made light of pedophilia and rape — was one that was mulled and actually made months ago, following conversations with Disney studio leadership and the team at Marvel Studios. Why the change of heart? After the firing, Walt Disney Studios president Alan Horn met with Gunn on multiple occasions to discuss the situation. Persuaded by Gunn’s public apology and his handling of the situation after, Horn decided to reverse course and reinstate Gunn.

The social media messages were indefensible, but the filmmaker never did anything but blame himself for poor judgment displayed at a time when he was emerging from the Troma film factory and attempting to be a provocateur. There were no reports that Gunn ever engaged in the behavior he lampooned. Unlike the defensive posture exhibited by Kevin Hart that led him to skip hosting the Oscars, Gunn fell on his sword early and often and never lashed out at Disney.

Ultimately, Gunn’s missives were poorly chosen words and not actions, though Disney’s quick trigger was completely understandable when the social media messages were first reported by outlets like Fox News. Those outlets reported that Gunn’s missives were exposed as payback for Gunn being a vocal critic of President Donald Trump.

Gunn’s return to “Guardians of the Galaxy 3” got complicated when he signed on to write and direct the “Suicide Squad” sequel for Warner Bros and DC. Marvel Studios has agreed to commence production on “Guardians of the Galaxy 3” after Gunn completes “Suicide Squad 2.” Making the whole thing easier though was the fact that Marvel Studios never met with or considered any other director for “Guardians of the Galaxy 3,” despite speculation that “Thor: Ragnarok” helmer Taika Waititi and “Vice” helmer Adam McKay were in the mix.

Marvel Studios has remained mum on all details concerning “Guardians of the Galaxy 3,” as the Kevin Feige-led division turned its focus toward “Captain Marvel” and “Avengers: Endgame.” Marvel this week set Destin Daniel Cretton to direct “Shang-Chi.”

Prior to his dismissal, Gunn had written a script which Marvel confirmed would be used for the third “Guardians of the Galaxy” installment. Deadline expects Gunn to confirm all this as he supports the release of “Brightburn,” the David Yarovevsky-directed Elizabeth Banks-starrer that he produced and Sony releases May 24.

There will be an inevitable chorus of those who will gripe about Gunn’s return, but creatively, “Guardians” will benefit from his return. The entire cast of the film was outspoken in its desire to have Gunn back, saying that those satiric tweets did not match his personal actions. The cast clearly loves him; Chris Pratt, Zoey Saldana, Dave Bautista, Vin Diesel, Bradley Cooper, Sean Gunn, Michael Rooker and Pom Klementieff all pleaded for Gunn’s return, in an open letter. The controversy shattered the camaraderie that the cast had with the filmmaker and put a strongly performing franchise in limbo. Marvel has done a great job allowing its filmmakers to inject their personalities into each franchise, and perhaps none has been as stamped by one filmmaker as Gunn on the “Guardians” franchise. The first two installments grossed over $1.6 billion worldwide, with the sequel out grossing the first picture.

Soon after the announcement of Gunn’s firing, fans circulated a petition urging Disney to reconsider. On Oct. 31, a fan crowdfunded billboard went up in Anaheim, Calif., to rehire Gunn.

Disney is days from closing its acquisition of the assets of Fox, and while the company will always be family- first, it is somehow reassuring that there is room for second chances and for a good director to have a chance to overcome a colossally stupid mistake.

UTA and The Safran Company rep Gunn.