When Harvey Milk was elected to the San Francisco Board of Supervisors in 1977 he was, as Time magazine would later observe, “the first openly gay man elected to any substantial political office in the history of the planet.”

Although Milk was assassinated by Dan White, a distressed former Board colleague, less than a year after taking office, his legacy of activism and hope, of ambition and authenticity, has endured and inspired a generation of LGBT leaders. In 1999 Time named Milk one of its 100 “Heroes and Icons” of the 20th century.

Now, on the 30th anniversary of his death, Milk’s story hits the big screen in November with the release of director Gus Van Sant’s “Milk.” Academy Award-winning actor Sean Penn (“Mystic River”) takes on the role of the colorful and charismatic LGBT icon.

“[Milk] came into power at a really important time in the history of gay rights in America,” says Dan Jinks, one of the producers of “Milk,” referring to the wave of anti-gay legislation sweeping the country at the time.

Milk became an outspoken opponent of California’s Proposition 6, a ballot initiative pushed by conservative state Sen. John Briggs that would have allowed school districts to fire teachers simply for being homosexual. Ironically, the Briggs Initiative was soundly defeated a few weeks before Milk’s assassination.

“It was so essential to the LGBT movement to have a leader in place who was effective at stopping something that really needed to be stopped,” Jinks says.

When screenwriter Dustin Lance Black (HBO’s “Big Love”) asked Jinks and his producing partner Bruce Cohen to take a look at his script about Milk’s unlikely rise from Castro Street camera shop owner to political pioneer, the Oscar-winning producers of “American Beauty” were quickly hooked.

“It was such a phenomenally written screenplay and, let’s face it, Gus Van Sant is one of the best directors on the planet,” Jinks raves.

The question of who should play Milk was answered quickly when Jinks, Cohen, Van Sant and Black put their heads together and unanimously agreed that Sean Penn would be their first choice.

“We felt that we should be able to get somebody sensational to play the part because it’s such a great story, it was such a strong script and it’s a brilliant part,” explains Cohen.

Like the mercurial actor playing him, Milk was a bit of a rebel. The native New Yorker made his way to San Francisco in the early ’70s, finding the city’s hippie climate more to his liking than the self-consciously bohemian Greenwich Village he left behind.

His Castro Street camera shop became a fixture in gay San Francisco and served as headquarters for his unlikely attempts to get elected to public office. Milk lost three elections before finally winning a seat on the Board of Supervisors in January 1978. A fellow freshman on that Board was San Francisco firefighter Dan White.

In addition to Milk’s political accomplishments, the filmmakers wanted to show his personal journey, “which is absolutely every bit as interesting,” Jinks says, “and what got this guy to do what he ended up doing.”

Among the actors who signed on to play Milk’s close friends and associates are James Franco (“Spider-Man”) as Milk’s lover, Scott Smith, Emile Hirsch (“Into the Wild”), Diego Luna (“Y Tú Mama También”) and Lucas Grabeel (“High School Musical”). Victor Garber (“Alias”) plays Mayor George Moscone, while Josh Brolin (“No Country For Old Men”) takes on the role of the tortured, tragic assassin, White.

The cast includes straight actors playing gay characters, gay actors playing straight characters and every other combination. “We wanted to have sexual preference-blind casting,” says Cohen. “For this movie to have not included all those different permutations, we felt would have been a mistake.”

It was also important to the filmmakers that “Milk” be shot entirely on location in San Francisco — and largely in the Castro District. “San Francisco, to us, is a character in the movie,” Jinks says warmly, explaining the refusal to substitute more cost-effective or efficient locations.

“There’s no place to park a car in San Francisco, let alone set up an entire base camp,” he adds, “but we felt pretty passionately that we had to do it.”

Jinks and Cohen emphasize that city officials and, in particular, residents and merchants in the Castro welcomed the production with open arms — even as the film’s crew transformed contemporary storefronts into 1970s streetscapes.

Just as it was crucial to the filmmakers to recreate the look of the era, they were also determined to accurately capture the cultural climate of the time. The pre-AIDS period was one of uninhibited sexuality, something Penn was characteristically fearless about depicting.

“He wanted to push the envelope in terms of the physical expression of his character’s homosexuality,” Jinks says. He explains that Penn wanted to dismantle the audience’s preconceived notions of him as quickly as possible.

For an off-handed example, when describing circuit party performer Flava’s portrayal of ’70s gender-bending disco king Sylvester in the film, Jinks notes, “He’s quite brilliant and, like many others, got a big, fat, wet onscreen kiss from Sean Penn.”

Despite Milk’s historical significance, his story is not widely known today, even within the LGBT community. “In a weird way, we’re actually excited,” Cohen says. “It’s not like, ‘Oh, him again!’ It’s quite the opposite.”

And if Cohen, Jinks, Black and Van Sant felt a personal importance as gay men in telling this story, it “only helped to serve the film,” Cohen says.

He emphasizes that the goal was “to make a film that is entertaining and emotional. Not just to the people that know the Harvey Milk story going in, but more importantly to the people — gay and straight alike — who don’t know Harvey Milk, and who are going to come to this movie with a fresh slate. Hopefully, we’re going to take them on a really beautiful journey.”

In May, a bust of Harvey Milk was unveiled outside San Francisco City Hall. The same month, the California Assembly voted to declare May 22 “Harvey Milk Day” in the state.

— “Milk” (Focus Features) will be released to movie theaters Nov. 26.