Dani Alves “followed his heart” when deciding on Tuesday to agree to a new deal with Barcelona and remain for at least two more seasons.

The Brazilian right-back was out of contract at the end of this month and was widely tipped to leave the Nou Camp with some of Europe’s biggest clubs interested in signing him.

However, the 32-year-old has accepted a new deal with Barça that will keep him at the club at least until June 2017.

Alves tweeted: “I have followed my heart and the hearts of those who love me.”

With Barcelona, Alves has been able to enjoy two treble-winning campaigns, the second of those this season.

Alves became emotional while speaking on Sunday at the Nou Camp during Barça’s treble celebrations, nearly 24 hours after their 3-1 Champions League final triumph over Juventus in Berlin.

He shed some tears while telling the club’s fans that he would “always be one of them.” At the time, he seemed to be on the way out.

A fan and team favourite, Alves was a huge contributor to Barça as they clinched the Primera Division, Copa del Rey and Champions League titles for the second time in six years.

He made 45 appearances this season for the Primera Division champions, including 44 as a starter.

“I’m really happy Alves is staying,” Barcelona left-back Jordi Alba said to the Spanish media. “He is a great professional and a great person.

“I didn’t know what he would do, but I know he will continue to help us a lot.”

Barça midfielder Ivan Rakitic tweeted: “I’m really happy! I couldn’t imagine a changing room without you!!!”

Alves had until Tuesday afternoon to accept Barça’s offer, with the club’s board then resigning due to the presidential elections that have been called for this summer.

He was highly critical of the club just last month and said he didn’t feel “fully respected”.

Moreover, he claimed that Barça had only approached him with a contract extension once they lost their appeal to overturn a transfer ban imposed by Fifa for breaching rules on the transfer of players aged under 18.

The arrival of former Sevilla winger Aleix Vidal on Monday as Barça’s first signing also raised questions about Barça’s plans for Alves.

Vidal can also play as a right back but will not be able to compete until January 2016 because of the Fifa ban.

“I’ll be delighted if Alves stays,” Vidal had said. “He is one of the best if not the best right-back in the world.

“There will be a healthy competition between us and that can only be good for the team.”

Alves, who joined the Catalan outfit in 2008 from Sevilla, has helped Barça win five Primera Division titles, three Copa del Rey trophies and the Champions League three times.