The SPFL said the deal, which comes into effect at the beginning of next season, was the "biggest ever of its kind in Scottish football" although it did not specify the exact figure it would raise.
Since Clydesdale Bank declined to renew its £2m sponsorship in the summer of 2013, the SPFL - which makes up all four divisions of Scottish football - has struggled to find a much-needed financial backer.
Ladbrokes will be the title sponsor of all four leagues, which will be officially referred to as the "Ladbrokes Premiership", the "Ladbrokes Championship" etc.
SPFL chief executive Neil Doncaster commented:
As an established and respected leading brand in its very competitive marketplace, Ladbrokes is a perfect partner for the SPFL and we have a shared vision of a positive future for professional league football in Scotland.
Today's announcement is the result of significant investment of energy and effort and further strengthens our optimism about the future health of the game in Scotland.
With all that positivity comes an opportunity to tell the story of a modern, engaging and exciting Scottish football environment and we look forward to doing just that with all out partners including new title sponsor Ladbrokes.
Doncaster's attempts to find a sponsor have been hindered by the financial uncertainty hanging over the Scottish game, which has forced a number of clubs to service their debts or face dissolution - a fate that befell Rangers, one of the country's biggest clubs.
Rangers' financial collapse and relegation out of the Scottish Football League in 2012 led to a collapse in TV audience figures, which in turn weakened the SPFL's bargaining position.
At the beginning of the year Doncaster told the BBC: "For so much of the time that we've been marketing this property, there's been a huge amount of uncertainty hanging over the Scottish game, initially from the merger when the Scottish Football League and the Scottish Premier League came together in the summer of 2013.