Authorities realised in 2016 that Spanish architect Antoni Gaudi's spectacular church had never been granted planning permission.
The unfinished basilica is one of Spain's biggest tourist attractions and is visited by more than four million people a year.
Construction began in 1882 and was nowhere near to being completed when Gaudi died in 1926 after being hit by a tram.
Barcelona City Hall gave the go-ahead for the construction of the basilica on Friday, following a provisional agreement last October.
The Sagrada FamÃlia Foundation said that the licence would allow it to "continue to build Antoni GaudÃ's project", which is expected to be completed in 2026, coinciding with the centenary of the death of its main designer.
The cathedral has a budget of 374 million euros (£332.5million). The licence alone cost 4.6 million euros (£4.1 million).
The construction board will also have to pay 36 million euros (£32 million) over ten years to cover public costs incurred by its activity.
Stay up to date with the latest news stories from a Christian perspective. Sign up to our daily newsletter and receive more stories like this straight to your inbox every morning.