As thousands of Muslim pilgrims swarmed around him, Parvez Sharma found a secluded corner on the second floor of the mosque in the middle of Mecca, took out his iPhone from his white robes and connected to the only available WiFi network: the Saudi Binladin Group. He FaceTimed his husband, Dan, who was at home in New York and surprised to be hearing from Sharma, who had embarked on his hajj, the once-in-a-lifetime pilgrimage to Mecca.

Was it a secure network? Dan immediately wanted to know. He was rightfully worried—in Saudi Arabia, being gay is punishable by death. And anyone spotted with a recording device on the grounds was chased and even beaten by religious police.

“I spoke to my husband all thanks to the Binladin Group,” Sharma says now, appreciating the irony. At the time, in 2011, just months after Osama bin Laden was killed, neither were sure Sharma would return from Saudi Arabia.

The two had recently wed in a ceremony in New York City, in the midst of celebrations over same-sex marriage legalization and just before Sharma left for what he calls his “hajj of defiance.” A few months later, Sharma took his fight for equality to Mecca.

This journey for acceptance is the subject of A Sinner in Mecca, the latest sure-to-be-controversial film from Sharma, a 41-year-old filmmaker originally from India. Armed with an iPhone 4S and two small cameras, Sharma goes undercover, masked twofold: as a filmmaker and a homosexual man. If he can complete the hajj, he believes that Islam has approved him as a gay Muslim.

“The risk I feared the most was that I would be found out and the Saudis would either lock me up or punish me by their routine methods of punishment that include beheading,” Sharma tells The Daily Beast. “So I was very afraid. But at the same time, as a religious Muslim, I felt I would be protected going on pilgrimage—divine intervention, even.”

The trip Sharma documented is the most sacred in Islam, a yearly event that draws more than 2 million Muslims to the ancient cities in Saudi Arabia and is forbidden to outsiders. The hajj is a re-creation of a journey taken by Islam’s ancestors and it contains its holiest sites.

By completing the hajj, a participant is forgiven for their sins. But Sharma was never sure he’d finish.

Sharma’s previous project, A Jihad for Love, was a 12-country voyage depicting the hidden pockets of homosexuality within Islam. It effectively outed him as an infidel when it came out in 2007. As a gay man, his sexuality was punishable by death in the tightly governed Saudi Arabia. But Sharma says the film traveled on an underground railroad, of sorts, and was even shown in clandestine screenings in the capital, Riyadh.

“I was a marked man,” he says in the film, dramatically.

Given his limited filming capabilities, the film is mostly narration and shaky documentary. Some of the scenes are long, but it’s a rare look at one of the largest human mobilizations on the planet.

Sharma chose to make his pilgrimage with other outsiders, even though he’s not technically one of them. He is a Sunni Muslim, but joins the minority Shia pilgrims, who are outliers in Saudi Arabia. He told no one of his filmmaking quest, but revealed his sexual orientation to another pilgrim, an American who’d made the journey with his wife and mother-in-law.

“Why would you want to be part of something that does not want to be part of you?” the man asked him.

But Sharma quickly discovers he isn’t the only sinner in Mecca. By surreptitiously recording conversations on his iPhone, he captures a man describing participation in an honor killing of his brother’s wife in Pakistan. He’d come to Mecca to be cleansed of the act that haunted him. That man, a killer, was seeking forgiveness, just as Sharma was. And who of them was the bigger sinner, in a world where many countries legalize honor killings but forbid homosexuality?

For both, the hajj was a promise of redemption.

“All Muslims arrive in Mecca already sinners. If you complete your hajj in the mandated way you are absolved of all sins and you get this one-way ticket to heaven. He assumed he’d be getting that ticket, but wasn’t sure. I assumed I would get that, but wasn’t sure either,” Sharma says of the synchronicity. “Believe me: Meeting him was not an accident.”

Sharma is devout, but skeptical of how his religion is being used.

“I need evidence that my faith is strong enough to survive this journey,” he says early on in the film. But soon, he’s wavering.

“If anything my faith seems to disappear in this very place,” he says later. He then doubts himself, wondering if he can be a good Muslim. But the project grows beyond his personal story and into an analysis of how the religion has been manipulated.

“I’m more concerned with Islam itself,” Sharma says now of the message he wanted to convey. “I think this is not a film about gay Muslims. This is a film about Islam and everything that ails it in the 21st century.”

It’s also a critique of the commoditization of the hajj in Saudi Arabia, where Sharma films pilgrims in the nearby mall Starbucks, robed men sipping coffee out of cups missing the notorious mermaid logo, and a call to action in a country that was barely shaken by the Arab Spring.

Saudi Arabia’s longtime ruler King Abdullah died this year, and a slightly younger successor has taken his throne. But revolution does not appear to be on the horizon. Gays are still persecuted and women are still barred from driving. Public beheadings aren’t uncommon.

“I would hope that work like this shakes a little bit the foundations of the Saudi monarchy,” he says.

The movie will premier at Hot Docs in Toronto in late April, and then travel to a number of film festivals worldwide. It was announced last Tuesday with a press conference, and Sharma has already received more than 100 hate letters, at last count, a few of which he’s posted on his new website.

“To be honest, I expected this, but I didn’t expect so many so soon,” he says. “I totally planted my resolve. I have to do this. I have to do this because of this [hate].”

But Sharma does recognize his vulnerability as being both filmmaker and subject: It’s his face and voice that comprise the story. And he’ll be continuing to publicize the story after the film by turning it into a memoir. “I do feel a sense of dread at times with what might be coming as reaction from extremist factions of Islam,” he says.

“I don’t want to cloud the message and frame it only in terms of the hate,” Sharma says. “I’m really waiting for positive responses from Muslims.”

But these have still yet to come, apart from friends on Facebook.

Still, he now knows that his last film circulated widely in Saudi Arabia’s underground, and he’s certain there are Saudis waiting for the next spotlight to be shone on homosexuality in the Muslim world. They’re in the closet, and he is not.

For him the exposure was temporary. For them, it’s a constant pendulum between life and death.