Guardians of the Galaxy director James Gunn has been removed from the franchise's third installment after several of his offensive tweets were unearthed this week

Director James Gunn has been kicked off the set of Guardians of the Galaxy Vol 3 after several of his old tweets containing offensive jokes were unearthed this week.

Gunn - a vocal critic of Donald Trump who frequently calls out Republican leaders on Twitter - was removed from the Disney franchise's third installment after conservative news site The Daily Caller drew attention to several of his controversial tweets.

The since-deleted posts featured jokes about sensitive topics including pedophilia, rape, the 9/11 terror attack and the Holocaust.

Among them was one where Gunn wrote: 'I like when little boys touch me in my silly place.'

In another he says: 'The best thing about being raped is when you're done being raped and it's like "whew this feels great, not being raped!"'.

Nearly two dozen other tweets mainly in 2008 and 2009 were captured in screengrabs before Gunn deleted his Twitter Friday.

The since-deleted posts - most of them from 2008 and 2009, featured jokes about sensitive topics such as pedophilia, rape, the 9/11 terror attack and the Holocaust

OAN correspondent Jack Posobiec and right-wing commentator Mike Cernovich were reportedly among the conservative personalities who unearthed the tweets this week, according to Fox News.

The Daily Caller's expose came after Gunn mocked conservative pundit Ben Shapiro earlier this week while defending liberal actor Mark Duplass, who came under fire for encouraging his fans to follow Shapiro to hear views from the other side of the aisle.

Fox News reports that Gunn's comments motivated the dig through the filmmaker's social media history.

All of the tweets were posted before Gunn joined the Marvel Universe in 2014, but executives at Walt Disney Studios have decided to cut ties with him regardless.

'The offensive attitudes and statements discovered on James' Twitter feed are indefensible and inconsistent with our studio's values, and we have severed our business relationship with him,' chairman Alan Horn in a statement.

Gunn directed the first two movies in the Guardians of the Galaxy franchise and was in the middle of writing the third installment - filming this fall - when Disney severed ties with him

Gunn defended himself on Twitter Friday before deleting his account.

'Many people who have followed my career know when I started, I viewed myself as a provocateur, making movies and telling jokes that were outrageous and taboo. As I have discussed publicly many times, as I've developed as a person, so has my work and my humor,' he wrote.

'It’s not to say I’m better, but I am very, very different than I was a few years ago; today I try to root my work in love and connection and less in anger. My days saying something just because it’s shocking and trying to get a reaction are over.

'For the record, when I made these shocking jokes, I wasn’t living them out. I know this is a weird statement to make, and seems obvious, but, still, here I am, saying it.

'Anyway, that’s the completely honest truth: I used to make a lot of offensive jokes. I don’t anymore. I don’t blame my past self for this, but I like myself more and feel like a more full human being and creator today. Love you to you all.'

Gunn had been writing the script for Guardians 3 and was set to start filming in Atlanta this fall.

The studio has not commented on who may take his place in the movie expected to be released in 2020.