Deadline reported that Gosling initially passed on playing Barbie's perennial love interest, but eventually acquiesced after the studio remained persistent in his casting and the two-time Oscar nominee's schedule opened up following a delay in the movie's pre-production process.
Filming is expected to begin in the new year.
A representative for Gosling did not immediately respond to PEOPLE's request for comment.
Rodin Eckenroth/Getty Ryan Gosling
Gerwig, 38, co-wrote the script with her partner Noah Baumbach, another filmmaker known for smaller and moodier fare such as The Squid and the Whale.
In addition to her on-screen role, Robbie — a two-time Academy Award nominee as well — is billed as a producer for the film under her LuckyChap Entertainment production company.
RELATED VIDEO: Mattel Launched Gender-Neutral Dolls Allowing 'All Kids to Express Themselves Freely'
The Bombshell actress, 31, opened up about the project in her August 2021 cover story with British Vogue.
"People generally hear 'Barbie' and think, 'I know what that movie is going to be,' and then they hear that Greta Gerwig is writing and directing it, and they're like, 'Oh, well, maybe I don't...' " she said.
Robbie added with a smile that the role "comes with a lot of baggage," considering some historical controversy over the doll.
"And a lot of nostalgic connections," she continued. "But with that come a lot of exciting ways to attack it."
Todd Williamson/NBC/NBCU Photo Bank via Getty Images Margot Robbie
Never miss a story — sign up for PEOPLE's free weekly newsletter to get the biggest news of the week delivered to your inbox every Friday.
Last year, Robbie told The Hollywood Reporter that the movie will sure to surprise people.
"We like the things that feel a little left off center," Robbie said of LuckyChap Entertainment, which she runs alongside husband Tom Ackerley and their longtime pal Josey McNamara "Something like Barbie where the IP, the name itself, people immediately have an idea of, 'Oh, Margot is playing Barbie, I know what that is,' but our goal is to be like, 'Whatever you're thinking, we're going to give you something totally different — the thing you didn't know you wanted. '"
"Now, can we truly honor the IP and the fan base and also surprise people? Because if we can do all that and provoke a thoughtful conversation, then we're really firing on all cylinders," she added.