Happy 49th anniversary to “Star Trek,” which debuted on NBC Sept. 8, 1966. It’s a remarkable success story due to its longevity, its fan loyalty, its philosophical-spiritual meditations — and its racial integration.

When Gene Roddenberry insisted on an integrated crew for Starship Enterprise, it wasn’t a TV first, but it was a rarity. In 1966, interracial marriage was still illegal in 17 states — one-third of the U.S. George Wallace’s inauguration speech in January 1963 included his rallying cry “Segregation now, segregation tomorrow, segregation forever!” Even though the Civil Rights Act passed in 1964, acceptance was slow: In the 1968 presidential election, Wallace won nearly 10 million votes and carried five states.

Meanwhile, show business was aiming for more integration, but then — as now — the intentions were better than the results.

In March 30, 1966, six months before “Star Trek” debuted, Daily Variety carried a story about a TV integration study. A team at UCLA had monitored all seven L.A. TV stations (three network affiliates, four locals) for content. The survey counted 1,197 speaking parts in primetime TV during one week in December. Only 40, or 3.36%, of the roles were played by black actors. Even worse, primetime TV ads included 1,371 speaking roles, of which 0.65% were black. The ACLU, which called the press conference, added a note that not all these characters were positive: Blacks were often cast in dramatic roles “which fortify the stereotype of the angry Negro who is a threat to society.”

When Roddenberry was a freelance TV writer, he was asked to join the 1959 series “Riverboat.” However, the producers didn’t want black characters on the show; they argued with Roddenberry so much that he exited.

In retrospect, the casting of Nichelle Nichols as communications officer Lt. Uhura and George Takei as Lt. Sulu seems like a perfect fit. But the roles were radical at that time, since both were in positions of great authority. Even so, Nichols planned to leave after the first season, to return to her stage and singing work. But she met Martin Luther King Jr. at an NAACP event and he urged her to stay, because Uhura was a positive role model who was needed. On Nov. 22, 1968, Nichols and William Shatner’s characters shared a kiss. Network brass was nervous, but the public had a more positive response.

“Star Trek” was expensive and ambitious. On Sept. 27, 1966, just after the series had debuted, Desilu production chief Herbert Solow complained to Variety about the costs. Solow said “Trek” and the other new series from Desilu, “Mission: Impossible” on CBS, were among the most expensive shows on the air. Each network paid about $145,000 per episode, which meant Desilu was having to pay out of pocket to keep up the quality on both shows. Solow fretted about the costs, saying, “Our only hope is to rerun them globally and that the shows will go on for five years.”

The original “Star Trek” series only lasted three seasons, but nearly 50 years later, folks are still watching both series. So it turns out Desilu’s investment paid off.