NEW YORK — For much of his career, Jude Law has been the archetypal leading man, relying on good looks and charm to land featured parts and deploying them smoothly on screen. But over the past few years, edge and grit have crept into the actor’s roles.

That transformation reaches its apex with “Dom Hemingway,” showing now in limited release and opening widely this month. The 41-year-old plays a violent down-on-his-luck crook, sometimes unrecognizable and often despicable, in the film, a character piece in genre clothing from writer-director Richard Shepard (“The Matador”).

Gone and buried is the unctuousness of Law’s Oscar-nominated turn as Dickie Greenleaf from “The Talented Mr. Ripley” or his breezily winning “Alfie.” Present and very much alive? The self-defeating rage of characters like “Taxi Driver’s” Travis Bickle or even, in its way, a reinvention of Ben Kingsley’s vile gangster in “Sexy Beast.”

“There was once a part of me that was frustrated by a public perception as this sort of young pretty thing,” Law said over lunch on a trip to the city from London recently. “This is a very good opportunity to put all of that to bed.”

That might be an understatement. At the start of the film, Hemingway is seen as he is released from prison, having served a 12-year sentence instead of squealing on his former boss, a Russian baddie named Ivan Fontaine (Demian Bichir). Upon his release, Hemingway seeks out Fontaine at his French country estate and demands recompense. He is granted it, but Dom being Dom, it isn’t long before he has mucked things up and landed himself in desperate straits.

Marked by a grandiose narcissism, a bleak sense of humor and a lyrical streak – not to mention some mean mutton chops – Law’s Hemingway is all working-class English brine, intelligence simmering beneath the menace, with a sense of humor he displays even as he beats men to within an inch of their life.

“I am a legend, a myth, a glorious tale to be handed down from generation to generation,” Hemingway boasts of his safecracking abilities even as a man threatens him with grievous harm. In the midst of a tantrum he tosses in a surprising cultural reference – “I’ve seen death, I’ve seen evil,” he yells, then finishes, “I’ve seen fire, I’ve seen rain, I’ve seen lonely days I thought would never end.”

The character’s piece de resistance is an opening monologue, much of it unprintable, in which he proclaims the greatness of his own genitals such that the organ in question is variously lauded as able to save starving children in Somalia and win a Nobel Peace Prize.

“I remember reading the script and thinking, ‘This is such a rare combination. There’s a scale of car crash to this guy, not just one car but a huge highway pileup,’” Law said. “And yet I was also curious about the poetry in the mouth of this uneducated man.” (While shooting the film, the actor noted “there was a volume to my existence, with too many late-night whiskeys and cigarettes.” Anything for a role.)

The casting was counterintuitive, to say the least, not only because of Law’s acting past but because his public persona was for many years as a celebrity tied up with well-publicized tabloid exploits and relationships.

“I was looking for an actor who had not done anything like this before, because I thought that would surprise audiences the most,” Shepard said. “I was looking for an actor who had done Shakespeare. And I was looking for an actor who’s starting to shift from playing a leading man to something else. And all those roads led to Jude.”

That choice, though, was in a sense the easy part. Shortly after a productive first meeting in London, calls from Law’s representatives to the filmmaker began slowing things down and the director sensed something was amiss.

“I could tell he was getting cold feet,” Shepard said. “If you’re writing material that puts actors in places they’ve never been before, that’s what can happen.” Shepard flew to London for a second time and convinced Law he didn’t want to make a straight crime movie, the apparent source of anxiety for the actor (indeed, despite the genre trappings there is no traditional heist here; the film is primarily about a man who can’t get out of his own way).

Gregarious and outgoing in person, Law says he also was coming off playing the animalistic, verbally limited sailor in “Anna Christie,” a London revival of the classic Eugene O’Neill drama. The 2011 production earned Law rave reviews but left him, he said, hungering for a role that contained bursts of words to match the explosions of violence.

“Dom’s” spittle-flying monologues were also a tuneup of sorts for playing another grandiose figure, Henry V, which Law did on the West End following the “Hemingway” shoot, in a performance that has earned him an Olivier nomination. (Juicy theater roles, incidentally, are also a latter-career Law trademark.)

Law offered the actor’s demurral that he’s simply going where the interesting parts take him. But he admitted that he has been wandering quite a bit afield lately – there was also the conspiracy theorist in Stephen Soderbergh’s “Contagion” and the manipulated doctor in Soderbergh’s “Side Effects,” as well as the cuckolded Alexei Karenin in “Anna Karenina” – and stopped himself in the middle of the interview. “I guess I’m using the word curious a lot.” He laughed quietly. “Curious Jude.”

Why he’s doing this is of course partly a matter of circumstance, as Law ages out of parts, particularly superhero ones, that in today’s Hollywood increasingly go to actors barely half his age, and with youthful looks and hair to match.

But the reinvention also echoes that of Matthew McConaughey, another star who grew weary of playing the light charmer, and began seeking out the tough scripts so that, bit by bit, we started to see him in a new light.

F. Murray Abraham, who worked opposite Law for the actor’s small part in Wes Anderson’s “The Grand Budapest Hotel” (and a man familiar with the transition from leading man to character actor in his own right) suggested not taking Law’s move lightly.

“The fact that he’s intellectually made that choice and said this is what he’s willing to do suggests there are no ego problems. Because it’s not an easy thing to do. It’s hard to give up what you’re good at, and there’s a lot of risk; you can fail and people will just stop thinking about you.”

Next up for Law is the recently shot Kevin Macdonald submarine drama “The Black Sea,” a kind of third leg in the tripod of wounded masculinity that began with “Dom” and continued with “Henry V” – “it’s full of grizzled blokes running and sweating and grunting, very butch,” Law said of the submarine picture. And he’ll be a foil of sorts as a CIA officer in the soon-to-be-shot Paul Feig movie, “Susan Cooper,” a smaller role that will let him riff with some hot comedy talent including Melissa McCarthy.

Law also said he’s had meetings recently with Guy Ritchie and others for a reprisal of his Dr. Watson character in a third “Sherlock Holmes” movie, though there’s nothing imminently in the works.