In 1958, Mildred and Richard Loving were sentenced to prison for violating a Virginia law forbidding interracial marriage — a case that eventually led to the Supreme Court overturning such laws there and in other states.

Now, that story has been turned into the movie “Loving,” opening Friday and starring Joel Edgerton and Ruth Negga as the Lovings.

“Doing this film was the luckiest I’ve ever felt about diving into any project,” Edgerton said in an interview. “We’re only as good as our director is — in this case Jeff Nichols, who also wrote such a brilliant screenplay — and the story we have to tell. This is one of the most important and interesting stories I’ve ever seen.”

The “Black Mass” and “The Great Gatsby” actor said his aim was to be true to the life of the man he portrays — and to help make sure the movie actually got made.

He said he “was terrified on the run-up to our filming. I was very afraid that this project would fall over and not get made, like movies often do. So many projects never end up getting made, no matter how worthy they are.”

The first time he got to see the finished movie, Edgerton said, “I was very emotionally connected to it. And I don’t mean because I’m in it. I mean as an audience member. Usually, it’s a subjective thing watching your own movies. But this was different. I was standing back, happy about the ultimate Supreme Court decision, but I did feel a very deep anger.

“I was so angry about how long it took for two people to be allowed to be legally married to each other — literally many, many years. It also deeply bothered me how the film shows all those people intervening in what should be a totally private thing between two people who simply are in love and want to be married to each other.

“This is still happening today. Today, it’s about same-sex couples getting married. What business is it of anyone but the two people involved?”

For Nichols, choosing Edgerton and Negga to portray the Lovings was an easy decision. Nichols had directed Edgerton in “Midnight Special,” for which he had also written the script.

“When we made that film, I saw how easily Joel picked up accents and voices,” Nichols said of the Australian actor. “I knew we had many examples of the image and voice of Richard Loving, so I knew he could absorb it right away.”

And Nichols joked that, “If you close one eye, and think about him losing some weight and dying his hair blonde — and give him a mouthful of bad teeth — you can see him as Richard Loving.”

For Negga, Nichols said, “That was the easiest casting job I’ve ever had on any project. She just showed up and started to read a scene, and it was obvious she was Mildred. She simply inhabited the role immediately.

“Both of these actors have such humanity in them. I could see right away they would easily be able to play these two people.”

Nichols said it was important for him to make the movie because “today we still are dealing with a lot of the concepts we examine in the movie. It’s amazing that equality is simply not something you just achieve. It’s not a box you just check off, and then you’re done.

“It’s still this thing we have to constantly redefine and re-evaluate. It is something we have to constantly strive for.”