Said Mohamed, a Muslim, plays a gay man in a new film, Colonial Gods, which is being premiered at the gay and lesbian Iris Prize Festival in Cardiff.
Festival organiser Berwyn Rowlands said it had been "almost impossible" to get actors who are Muslim to play the main parts because of the gay content.
The film is being shown in Chapter in Cardiff on Wednesday.
The 24-year-old actor, who has lived in Cardiff for seven years, said: "I was aware of the gay content in the film but this did not bother me.
We found it almost impossible to get Muslim actors to play the main parts
Festival organiser Berwyn Rowlands
"I am a Muslim but I approached the project in a professional manner, as I hope most actors would."
The film, produced through the Iris Prize Festival, is the result of a group of American film-makers, including inaugural Iris Prize winner Dee Rees, working with a group of their Welsh counterparts.
Mr Mohamed, who is not gay, plays the role of Abdi, a gay character who plays a key role in the film as it explores the tensions between religion and sexuality.
Festival organiser Berwyn Rowlands said: "We found it almost impossible to get Muslim actors to play the main parts. The gay content is not something they would consider doing.
"For us it was amazing that Said, a young student who is Muslim, said he would love to play that role."
The film is set in Cardiff and looks at the transformation of the docklands area around the multicultural community of Butetown into a fashionable residential and entertainment district.
Mr Mohamed, who was born in Somalia in east Africa, said: "It’s highlighting some of the history before the new Cardiff Bay was built, the community that was there and the reason it was there.
"That community is still around and has settled. Their kids have had kids and settled. You see a lot of people from Somalia and Yemen living there."
His own family history has followed a similar pattern because of the dangers posed by life in Somalia.
"Due to the civil war in Somalia we fled to Europe, where we sought asylum," he said.
"Like many other refugees, we got dispersed as a family and some of us ended up living in France, the Netherlands and the UK. I followed my mother to the UK."
He added: "The character Abdi is from Somalia and we both experienced war and I feel personally I relate to his journey from Africa to Europe.
"That was a bit of the excitement that I wanted to show."
Mr Mohamed, who graduated in drama at the University of Glamorgan near Pontypridd, is now happy to call Cardiff home.
"I like Cardiff – I have a lot of friends. It’s a great city which is growing and growing," he said.
BBC One soap EastEnders currently features a storyline about a Muslim man embarking upon a gay affair.
The storyline was criticised by Asghar Bokhari, of the Muslim Public Affairs Committee, who said the programme had missed an opportunity to present a "normal, friendly Muslim character" to the British public.
The Iris Prize Festival takes place in Cardiff from Wednesday to Saturday.