The Circuit de Barcelona-Catalunya has one of the longest unbroken runs of any current grand prix venue, having been on the calendar continuously since its first race in 1991.
The long-term future of the race had been unclear in recent seasons due to the close involvement of the local authorities, and the need for the event to make financial sense.
F1 has stressed that the venue, which was built in the run-up to the 1992 Barcelona Olympic Games, will be upgraded in order to bring it into line with more modern venues on the schedule.
A statement noted: "We want to thank the promoter and the authorities for their engagement and support and look forward to continuing to build our relationship in the years ahead.
"As part of the new agreement, improvements to the track and facilities will be made ahead of the race on May 22 2022, including upgrades and improvements towards the circuit's ambitious sustainability plans."
"We are delighted to announce this deal with Circuit de Barcelona-Catalunya," said F1 CEO Stefano Domenicali.
"I want to thank the promoter and the authorities for their enthusiasm and commitment to keeping Formula 1 in Barcelona, with improvements that will be made to the track and facilities, and continuing our long history together.
"The teams and drivers always look forward to racing at the circuit and visiting Barcelona, and the Spanish fans will continue to see their national heroes, Fernando Alonso and Carlos Sainz, up close."
Roger Torrent, the Catalan minister of business and labour and also president of the circuit organisation, made it clear that the sustainability aspect was a key part of getting the deal done.
"We welcome the renewal of this contract, which includes a mutual commitment clause to help us turn Circuit Barcelona-Catalunya into a model and world benchmark of sustainability applied to this type of facility," said Torrent.
"We want the circuit to become an exponent of the green transformation and the adaptation of infrastructures to the demands of the climate emergency."
New MotoGP deal
The Spanish circuit also announced a new contract to host MotoGP at the venue, but alternating with other tracks in the Iberian peninsula.
The new deal covers until the 2026 season, with the Circuit de Barcelona-Catalunya hosting at least two MotoGP events between 2023 and 2026.
"This contract renewal with the Circuit de Barcelona-Catalunya for five more seasons is, without a doubt, fantastic news for MotoGP," said Dorna boss Carmelo Ezpeleta.
"The spectacular Catalan track has been linked to MotoGP since the first beginnings of Dorna and has been a key fixture on the calendar each season.
"This important agreement extending the collaboration until 2026 demonstrates, once again, the commitment shown to our Championship by the promoter."