The eight-time Ballon d'Or winner is still playing in the United States for Inter Miami and is expected to play a key role in Argentina's World Cup title defence this year.
"This move reinforces Messi's close ties to Barcelona and his commitment to the development of sport and local talent in Catalonia," the club said in a statement confirming the former Barcelona star's acquisition.
Several top players have come through the ranks at Cornella, including Arsenal goalkeeper David Raya and Messi's former Barca teammate Jordi Alba.
Cornella have suffered back-to-back relegations in the past two seasons.
"Leo Messi's arrival marks the beginning of a new chapter in the club's history, aimed at driving both sporting and institutional growth, strengthening its foundations, and continuing to invest in talent," Cornella added.
"The project is guided by a long-term vision and a strategic plan that combines ambition, sustainability, and a strong connection to its local roots."