Ron Stallworth, the first black detective to serve with the Colorado Springs police department, has carried a red identification card in his wallet for almost 40 years. In black letters, it says “Ron Stallworth CO 78862, Member in Good Standing for the Year 1979.” Then, along the bottom of the card in formal script: “Knights of the Ku Klux Klan.”

Mr. Stallworth joined director Spike Lee and actor John David Washington Monday night to talk about their new film, BlacKkKlansman, which chronicles his extraordinary undercover infiltration of the hate group. The conversation topped off opening day for the Martha’s Vineyard African American Film Festival, and hundreds filled the performing arts center seats.

“I keep it in my wallet for two reasons,” Mr. Stallworth said of the card. “One, it is a memento of my career, the other reason is if I’m ever in a fatal car crash, some poor cop is going to come along...” The end of that sentence was drowned out in a roar of laughter and applause.

As a police officer in Colorado in 1979 Mr. Stallworth infiltrated the Ku Klux Klan. — Mark Alan Lovewell

Mr. Lee did not screen the full film, which is set to open this Friday across the country, opting instead to show selected clips and talk to Mr. Stallworth candidly about his experiences.

Mr. Stallworth, who has written a book about his surveillance of the KKK, said he was scanning the newspaper at the police department when the idea occurred to him 40 years ago.

“I saw this ad that said, Ku Klux Klan. For information, there was a P.O. Box,” he said. “So, I said, what the heck.”

He sent a letter of interest detailing his Aryan pride and including a litany of slurs for other groups.

“I thought I’d get a pamphlet or a brochure or something like that,” he said. “About a week or two later, the phone rings in my office.” It was a lead organizer for the Colorado Springs chapter of the KKK.

“He said, I got your note, and I said, Oh hell,” Mr. Stallworth said remembering the moment. He stayed on the phone, and thus began his months-long infiltration of the Klan from within. Mr. Stallworth communicated with members on the phone and sent a white officer to pose as Ron Stallworth in person. At great personal risk, the two became privy to the organization’s secret rituals and developed contacts including former grand wizard David Duke. Mr. Stallworth said hype about the new movie prompted a recent unexpected phone call from Mr. Duke. The two hadn’t spoken since the 1970s.

Mr. Washington said he used music from the era to help get into character.

“He was very concerned about how he was going to be portrayed in the movie,” Mr. Stallworth said of the ensuing conversation, which he said lasted an hour.

“He should have thought about that a long time ago,” Mr. Lee interjected.

Mr. Washington, who is the son of actor Denzel Washington, said he used music to access his character and the era. He assembled a long playlist that included the music of Marvin Gaye and Jimi Hendrix. He said inspiration also came from the documentary, The Black Power Mixtape.

“Just seeing how coming off of Vietnam and the killing of Martin Luther King and JFK, people were just fed up,” he said. “They just wanted to express themselves. You saw it in their clothes, their music, their hair.”

He also had the opportunity to spend time with Mr. Stallworth to develop the character.

“He let me borrow his soul for a couple months to play him in this film,” he said, adding, “This man is a hero, an American hero.”

Mr. Lee told the crowd he first came to the Vineyard in 1978 when he was a student at Morehouse College. — Mark Alan Lovewell

Mr. Lee owns a summer home in Oak Bluffs and has come to the Vineyard for decades. This year, he shot scenes for his Netflix series, She’s Gotta Have It, on location on East Chop. He recalled his first visit to the Island in the summer of 1978 while a student at Morehouse College when he stayed at the summer home of a classmate’s family for the Fourth of July.

“I came up here and fell in love with Martha’s Vineyard,” he said.

Though the conversation was punctuated by laughs and cheers, the gravity of the film’s subject matter was never far from the surface. Mr. Lee took the last minutes of the discussion to point out that the one-year anniversary of the deadly Charlottesville white supremacist rally approaches this month. Scenes of that protest and its aftermath end the film.

“Even though this film takes place in the 70s, we still wanted people not to look at this as a history lesson,” he said. “This film is about today.”