Like anyone foolish enough, brave enough, or passionate enough to pursue acting as a career, Marion Cotillard has made her share of unremarkable, if not remarkably bad, films. But when the French star, who won the Academy Award for her unearthly reincarnation of Edith Piaf in “La Vie en Rose,” gets it right, the result is magic. Her Piaf, wide-eyed and woeful, was that. So was the whale trainer she played in the harrowing and heartbreaking “Rust and Bone,” a story of from-the-pits-of-despair resilience.

In the title role of James Gray’s “The Immigrant,” as Ewa, a destitute Pole who arrives in New York City on a fog-shrouded January day in 1921 in search of the American Dream, she once again astounds. In this fascinating, half-crazy endeavor, Cotillard’s Ewa is plucked from the deportation line – the immigration officers at Ellis Island have deemed her a woman of “low morals,” and are sending her back from whence she came. Her savior is one Bruno Weiss, who tells her he’s from Travelers Aid and hands the guard a few bills to facilitate Ewa’s hasty transfer to a Manhattan-bound boat.

In fact, Bruno runs a bevy of bawdy women in a shabby burlesque hall, offering their supplemental services to men willing to pay. He keeps his “little doves” several flights up in the tenement where he lives, bossing them with gentle urgency. It will come as no surprise, this being a James Gray movie, that Bruno is played by Joaquin Phoenix. The actor and the filmmaker have collaborated before, on “The Yards,” “We Own the Night,” and “Two Lovers.”

It also will come as no surprise that Phoenix plays this guy with a kind of unpredictable, flummoxed charm. He can be wily and confident one minute, needy and pathetic the next. When his luck goes south – a moment of profound downturn, as Bruno gets pummeled by a squad of nightstick-wielding cops – Phoenix emerges, bloodied, bowed, to deliver juicy chunks of dialogue like some opiated Brando. It’s hard out there for a pimp.

Bruno’s hold over Ewa is simple: Her sister, Magda, is in the hospital on Ellis Island, diagnosed with tuberculosis. It will require significant sums to pay for her care, and to pay officials to let Magda gain entry into the country. Though Ewa feels ashamed, dirty, steeped in sin, she beds down with men (and boys, her first client being a 15-year-old virgin sent to be “educated” by his pop). She and Bruno split the earnings, 50-50.

Of course, Bruno falls in love with Ewa. And of course, there is a rival: Emil, also known as Orlando the Magician, a glinty-eyed prestidigitator (watch him levitate! watch him read minds!) played with snaky charisma and a pencil-thin mustache by Jeremy Renner.

Bruno and Emil have a long history – in fact, they are cousins. No good will come of their battle for Ewa’s heart.

It’s a little freaky to watch Phoenix go at it, a smooth-talking beguiler who suddenly turns stumblebum. But there’s nothing freakish about Cotillard. She gives Ewa an inner life, full of ferocity, vulnerability, cunning. In her peacock feathers and her cheap flapper’s jewelry, or in a dark woolen shawl, huddled in the night, this woman is absolutely wondrous, absolutely real.