The 28-year-old Croatia international will sign the deal, which has a £109m (125m euros) buyout clause, on Friday.
Rakitic - whose current contract runs until 2019 - has made 145 appearances for Barca since his 2014 move from Sevilla, scoring 23 goals.
He played in Barca's famous 6-1 comeback win against Paris St-Germain in the Champions League on Wednesday.

Margaret Aspinall and Trevor Hicks campaigned for more than 20 years to secure fresh inquests into the deaths of 96 people in the disaster.
Mr Hicks' daughters Sarah, 19, and Victoria, 15, and Mrs Aspinall's son James, 18, were among those who died at the FA Cup semi-final in April 1989.
Mrs Aspinall, chair of the Hillsborough Family Support Group, said she would accept it on behalf of the families.
A jury is currently hearing the new inquests in Warrington before coroner Lord Justice Goldring.
Mrs Aspinall said: "It's not just about Trevor Hicks and Margaret Aspinall, it's about everybody involved in this. It's all about the people who stood by us.
"From the beginning, when you are fighting against everything, nearly 26 years ago, you had this stigma against you all the time, fighting against that, I feel we have turned it all around now and the stigma is going away.
"People are seeing now, the real people, what the genuine people are like, and the people who stood by the families and stayed with them all these years, so it's for them as well."
Mr Hicks, president of the Hillsborough Family Support Group, said: "On a personal level, obviously I'm very flattered. I know it's a bit cheesy but I'm also a bit humbled as well.
"It's not just for me. As it says in the citation, it's for services to the bereaved families.
"It's been a hard slog. We've been accused many times of being vindictive - and lots worse than that. But we've always tried, as a family support group, to play fair."
Fellow campaigner Anne Williams, who died in April 2013, was honoured with the Helen Rollason Award at the BBC Sports Personality of the Year Ceremony in 2013.
Ms Williams, 60, fought for a new inquest into her son Kevin's death.
Two investigations are being carried out into the aftermath of the disaster - one led by police and one headed by the Independent Police Complaints Commission.
Other Merseyside & Cheshire honours include:
CBE
OBE
MBE

Former Chester and Kidderminster boss Burr, 57, joined the Sandgrounders in September to replace Andy Bishop when they were second bottom.
But they have lost their last three games and are only a point above the National League drop zone.
Watson, 46, has spent eight years as manager at Southport in two spells.
"Following a disappointing series of results the board have taken the above decision in the best interests of Southport to move forward in a different direction," said a club statement.
"With 19 players recruited during Steve Burr's tenure and significant financial backing to strengthen the squad, the performances and results recently have not shown signs that confirm the club can get to a position in the league that provides the security as required."

The deaths plunged the community in the town of Arnstein into mourning.
The five young men and a woman, all aged 18 or 19, were found on Sunday by the landowner whose son and daughter were among the victims.
Police say a wood-burning stove was in use at the hut, but other possible causes are still being investigated.
"The six adolescents... died from carbon monoxide poisoning," said a police statement.
"The cause of the leakage of the toxic gas remains under investigation."
The owner of the hut said he had gone there after his children failed to return from the party the night before.
A neighbour told German media that his daughter had been celebrating her 18th birthday.
The brick building is some distance outside the town and the area was covered in snow.
The tragedy has caused an outpouring of grief in the town, which is about 30km (18 miles) north of the city of Wuerzburg.
An area has been set aside in the local church for flowers, candles and other tributes to the teenagers. A gathering for friends and relatives was held there on Monday "for grief, remembrance and prayer".
Barcelona midfielder Ivan Rakitic has agreed a new contract, tying him to the Spanish champions until 2021.
[NEXT_CONCEPT]
Two Hillsborough campaigners have been appointed CBE in the New Year Honours.
[NEXT_CONCEPT]
Southport have sacked manager Steve Burr after just over four months in charge, with director of football Liam Watson taking interim charge.
[NEXT_CONCEPT]
Six teenagers found dead in a garden hut in the German state of Bavaria died from carbon monoxide poisoning, police have said.