After just missing out on a handful of major roles, “Pan Am” star Margot Robbie has landed the female lead opposite Leonardo DiCaprio in Martin Scorsese’s “Wolf of Wall Street.”

Pic is based on the Jordan Belfort memoir and also stars Jonah Hill and Kyle Chandler.

It chronicles Belfort’s rise and fall on Wall Street, along with his hard-partying lifestyle and tumultuous personal life. Robbie would play Belfort’s second wife, Nadine.

Red Granite is financing, and principals Riza Aziz and Joey McFarland will produce along with Scorsese, Emma Tillinger Koskoff, Irwin Winkler, Alexandra Milchan, DiCaprio and his Appian Way partner Jennifer Killoran.

The part was a coveted role among actresses, given the material and talent working on the project. Teresa Palmer and Amber Heard were among others that had tested for the part several times before the decision went to Robbie.

Thesp was among the finalists for the female lead in Warner Bros. “A Winter’s Tale,” a part that eventually went to Jessica Brown Findlay, and she was considered the frontrunner for Paramount’s “Teenage Mutant Ninja Turtles” reboot before production on that pic was put on hold last week.

Robbie is repped by CAA, Management 360 and Aran Michael Management.