The director of two of the most successful Marvel movies is back after being fired last year for offensive tweets he'd made many years ago.

James Gunn, who wrote and directed Marvel's Guardians of the Galaxy movies, is returning to Disney to create the third instalment of the series, according to a message Gunn tweeted. According to a Deadline report, the decision to rehire the director was made months ago, after conversations between Disney and Marvel. Walt Disney Studios chairman Alan Horn was persuaded by Gunn's public apology and overall handling of the situation, The Daily Caller report says.

​After being ditched by Disney, Gunn made a deal with Marvel's arch-rival DC Comics to direct a sequel to Suicide Squad. The renewed contract with Disney says he will begin working on the new Guardians movie as soon as he is done with the DC movie, according to The Guardian. Gunn finished the script for the third Guardians movie before parting ways with Disney, BBC reports.

Gunn was sacked by Disney, the owner of Marvel, last July, over a series of tweets that Disney at the time called "indefensible". In his since-deleted tweets, Gunn reportedly made light of the 9/11 attacks, rape and paedophilia.

"[They are] inconsistent with our studio's values, and we have severed our business relationship with him," the company said in a statement at the time.

Gunn disowned the tweets after they came into spotlight in 2018.

"My words of nearly a decade ago were, at the time, totally failed and unfortunate efforts to be provocative," Gunn said at the time. "I have regretted them for many years since — not just because they were stupid, not at all funny, wildly insensitive, and certainly not provocative like I had hoped, but also because they don't reflect the person I am today or have been for some time."

The Guardians of the Galaxy cast, including Bradley Cooper, Zoe Saldana, Chris Pratt and Dave Bautista, has issued an open letter in defence of the director. Bautista, who plays the role of Drax the Destroyer, even vowed that he won't return for the next film unless Gunn returned.

"To be honest with you, I don't know if I want to work for Disney," the actor said at the time.

The first and the second Guardians of the Galaxy films are 13th and 8th highest-grossing Marvel movies of all time, making approximately $333 million and $390 million, respectively, leaving the two Iron Man movies, Thor, The Wolverine and the X-Men series far behind. The three most successful Marvel movies, Black Panther, Avengers: Infinity War and Marvel's The Avengers, grossed $700 million, $679 million and $623 million, respectively.