Director James Gunn at the El Capitan Theatre Hosts Screening Of Disney And Marvel Studios' 'Guardians Of The Galaxy Vol. 2' held at El Capitan Theatre on May 4, 2017 in Los Angeles, California.

James Gunn has been rehired by Disney's Marvel Studios to helm "Guardians of the Galaxy 3" after being pulled from the project last summer, a person familiar with the matter told CNBC.

The director was fired after social media posts he had made a decade ago making light of pedophilia and rape had been made public. However, the studio was swayed by Gunn's public apology and decided to reverse its decision and bring Gunn back into the fold. Deadline was the first to report the news Friday.

Earlier this month, Marvel Studios head Kevin Feige confirmed that Gunn's script for the third installment of "Guardians of the Galaxy" would be used when the film eventually began shooting. At that time, no comment was made about Gunn returning to the project.

Actors from the film including Chris Pratt, Zoe Saldana and Bradley Cooper signed an open letter last July asking the studio to reinstate Gunn.

Gunn was a writer and the director of the previous two films, which have become fan favorite movies in Marvel's Cinematic Universe for its plucky humor and use of '80s music.

"Guardians of the Galaxy" took in $773 million worldwide in 2014 and its sequel "Guardians of the Galaxy: Vol. 2" earned $863 million at the global box office.

Representatives for Disney were not immediately available to comment. The person who spoke to CNBC requested anonymity because the matter is confidential.

Gunn's reinstatement will not impact his commitment to write and direct "Suicide Squad 2," a DC comic film produced through rival Warner Bros which he signed onto last October. According to Deadline, Marvel has agreed to wait to produce "Guardians 3" until after Gunn completes "Suicide Squad 2."

Deadline also reported that Marvel Studios had not met with or considered any other director for "Guardians 3," despite rumors that Taika Waititi ("Thor Ragnorak") and Adam McKay ("Vice") were in talks for the position.