A passion project for director Sanjay Leela Bhansali since the 1990s, even before he made his directorial debut, Khamoshi the Musical (1996). The film was first announced in 2003. Bhansali initially wanted to cast Salman Khan and Aishwarya Rai Bachchan, his lead pair from Hum Dil De Chuke Sanam (1999), as the lead actors, with Bhoomika Chawla playing Kashibai, but his plans fell through when the real-life couple had a messy, highly-publicized breakup. Bhansali kept Khan on and approached Kareena Kapoor to play Mastani and Rani Mukerji to play Kashibai but shelved his plans and moved on to other projects after Khan and Kapoor both signed on to star in Kyon Ki... (2005), as he had wanted to be the first director to unite the pair, as he stated on the talk show Sanjay Leela Bhansali & Aishwarya (2004). Over the following decade, Bhansali kept expecting the project to be his next film, with several major actors being approached or rumored to be linked to the project, including Shahrukh Khan, Ajay Devgn, Hrithik Roshan and Katrina Kaif, while some in the industry believed it would never be made, calling it jinxed. The project was finally properly revived in 2014 when Bhansali finally decided on his lead actress from Mary Kom (2014), Priyanka Chopra Jonas, and his lead pair from Goliyon Ki Raasleela Ram Leela (2013), Ranveer Singh and Deepika Padukone.
The film's first song "Gajanana", sung by Sukhwinder Singh, was released on September 15, 2015. The song was launched at Shree Chhatrapati Shivaji Sports Complex, Balewadi Stadium in Pune in the presence of film's director Sanjay Leela Bhansali, Ranveer Singh and Deepika Padukone, where over 5000 students gathered and formed the biggest human formation of Lord Ganesha. Later, it was declared a world record by Guinness World Records for the largest human formation of a deity.
Tanvi Azmi had to shave her head for the film, so she had to turn down a role in Umesh Shukla's All Is Well (2015) .
Priyanka Chopra Jonas followed a 15-day coaching course to learn the Marathi language as spoken during Peshwa's time.
This came out on the same day as Dilwale (2015), marking the third time that a Sanjay Leela Bhansali-directed film and Shahrukh Khan-starring vehicle were released on the same day after their common Devdas (2002) in July 2002, and later the competing Saawariya (2007) and Om Shanti Om (2007), both released on Diwali 2007.