In his last match the 39-year-old captained Argentina to the final of last month's World Cup in New York, but was unable to prevent his nation losing 1-0 to Spain.
Handed a senior Argentina debut at the age of 18, Messi went on to play 207 times for Argentina and scored 125 goals.
His crowning moment came in 2022 when he led his team to World Cup triumph in Qatar, their third success but first since 1986. En route he scored as the albiceleste knocked out Australia.
"After the time that has passed since the final, and after giving it a lot of thought, I want to let everyone know that I am retiring from the national team," Messi said on Instagram.
"It is a decision that hurts and still hurts deep down but I understand that the time has come. I swear to you that I always gave it my all – not just in these last few years when we won everything, but before that too.
"I always fought and left everything on the field for this jersey, to bring you joy and make you feel proud to be Argentinian through football.
"Time is running short, chapters come to a close and this is one that hurts me deeply. I love, have loved, and will always love being part of the national team.
"I've given everything I had, I have nothing left to give and besides, there are some great young players coming up who deserve to be here."
Messi retired from playing for Argentina before, in 2016, after losing the 2014 World Cup final and back-to-back Copa America finals in successive years, but was persuaded to relent.
He subsequently led Argentina to the 2021 Copa America title, their major first honour in 28 years, and again in 2024.
This time his retirement is likely to stand.