LOS ANGELES — The difficult psychological aspects of “The Infiltrator” are what attracted Bryan Cranston to the role of a U.S. customs agent who went deep undercover to infiltrate the trafficking network of one of the world’s most notorious drug kingpins.

That individual was Robert Mazur, the agent who in 1986 used his alias of Bob Musella to get close to drug lords and their money-laundering schemes. He infiltrated Colombian drug mogul Pablo Escobar’s network, eventually taking down the Bank of Credit and Commerce International, which secretly had taken illegal ownership of First American Bankshares in Washington, D.C.

That led to Mazur writing his autobiography, the basis for director Brad Furman’s new film, which opens Wednesday.

Cranston says “it wasn’t just the plot line of doing good, bringing down the bad guys who were bringing drugs into the country that attracted me to this project. But it also was the risk that he had with his family. The fact that he had to separate himself from his family. That possibility of losing that contact with his wife was very present. I found that extremely intriguing as an actor.”

Beyond that, the “Breaking Bad” star says, “I was fascinated with how he developed such a bonding friendship with a bad guy” — Roberto Alcaino, played by Benjamin Bratt in the movie.

“Of course, my character, who is based on the real Bob Mazur, was a guy doing his job right. But to do it right, he literally had to infiltrate this arena and make a true friend — and then betray that friendship.

“Although it was justified — it was his job — all the same, it is a betrayal as he turns in his friend and arrests him. When I read the script, all I could think was, ‘Wow! What a story! I have to do this!’ ”

Working on “The Infiltrator,” Cranston got to know Mazur. He spent long hours talking with him about what he’d gone through in the mid-1980s.

“Bob Mazur is a very righteous guy,” says Cranston. “He is hellbent on benefiting the country and the society that he lives in. He was determined to do this and do it well, and he had an aptitude for it. Still, he’s human, and he has emotions just like the rest of us. He was concerned about life with his family, and he is so to this very day.

“He doesn’t go on camera full face on. Few people know what he looks like. I know what he looks like. But virtually everyone else in the public doesn’t know what he looks like or what he sounds like. He has to stay undercover because there are still some bad guys out there who want to take him out.”

Bratt says, in approaching the role of Alcaino, he knew little of the world of drug-trafficking and money-laundering when he signed on for “The Infiltrator,” but director Furman was a longtime friend.

“He was the 19-year-old kid who was the assistant to my agent when I was living in New York. Now, all these years later, things have come full circle, and he’s become a well-respected filmmaker,” Bratt says, noting that Furman’s credits now include “The Lincoln Lawyer,” which starred Matthew McConaughey.

After reading Mazur’s memoir, Bratt says, “I was struck by how cinematic it is. Now that the movie is completed, I believe it captures the tension and the sense of danger I got from reading the original book. Plus, it captures the conflicted loyalties that one feels toward a job — as opposed to a new, budding friendship that Mazur knew he would have to betray.”

As for his character, the actor says, “He is truly a criminal, but he’s also is a loyal family man, a good businessman and has many good character traits. That said, I never approach a character — even if he’s someone doing bad things — by prejudging who he is in terms of good vs. bad.”

Bratt says a bonus for him was “meeting with Robert Mazur and actually listening to the tapes of his conversations with Roberto Alcaino. That was an amazing resource for me as an actor.”