Sources told ESPN that Barca had considered leaving the number unused for the 2021-22 season, but LaLiga rules that first-team players must wear numbers 1-25 made that difficult.
Ansu, who returned to training recently following nine months out with a knee injury, had originally been given the No. 17 shirt for the upcoming campaign and has previously worn No. 22 and No. 33 since making his debut in 2019.
Messi, who joined PSG on a free transfer after his contract at Camp Nou expired, had worn the No. 10 at Barca since 2008, having previously worn No. 30 — the number he now wears in France — and No. 19.
The Argentina forward inherited the No. 10 from Ronaldinho, with Juan Roman Riquelme and Rivaldo among those to wear it before him.
Ansu, 18, has not played for Barcelona since injuring a knee against Real Betislast November. Following several operations, he returned to full training at the end of August, and Barca hope he will be available for action later in September.
A week later, he became the club’s youngest goalscorer in LaLiga when he netted against Osasuna, and in December of that year, his winning goal against Inter Milan made him the youngest scorer in the Champions League.
In total, he has made 41 appearances for the first team, scoring 13 goals.
Ansu will now form part of a new-look attack at Barcelona after Antoine Griezmann followed Messi out of the door on Tuesday, joining former club Atletico Madrid on loan with an option to stay permanently.
Barca responded by signing striker Luuk de Jong on loan from Sevilla, having already brought in Memphis Depay and Sergio Aguero on free transfers this summer. Martin Braithwaite and Ousmane Dembele, who is currently injured, are their other options in attack, along with youngster Yusuf Demir.