The deal on Thursday comes a day after club president Joan Laporta said Dembélé would stay on during the presentation of new signing Raphinha.
Dembélé, now 25, joined Barcelona in 2017 on a then club-record transfer from Borussia Dortmund that with variables was set to reach 147 million euros (then $173 million) as the club sought a young talent after the unwanted exit of Neymar.
After suffering serious injuries early in his stay at Barcelona, Dembélé consolidated himself as one of its most irreplaceable players thanks to his speed and playmaking.
The new contract concludes a drawn-out negotiation between player and club that appeared to have broken down in January when Dembélé rejected Barcelona's renewal offer, prompting the club to tell his agent to find the France winger a new club.
Dembélé continued to play well for coach Xavi Hernández and remained one of his most used players.
But with his contract expiring this summer, it appeared he would leave. Dembélé was linked to possible moves to England's Premier League or to Paris Saint-Germain, the team of Neymar and former Barcelona great Lionel Messi. Now he will be considered one of Xavi's pillars as the coach tries to build a winning side following a season without a title.
The forward has 32 goals and assisted on 34 more in 150 appearances for Barcelona.
As usual, Barcelona did not make his salary public. It is reported Dembélé had one of the highest wages on the squad under his previous contract. Barcelona has successfully convinced several players to take a wage cut as it tries to reduce its enormous debt.