The 38-year-old centre back made 139 appearances for his country and was part of the squad that reached this year's World Cup final in the United States, in which the defending champions were beaten 1-0 by Spain.
"Today I have to write the most difficult words of my career," Otamendi posted on Instagram. "As fate would have it, my last match was a World Cup final. It wasn't the result we wanted, but I'm leaving with my head held high, knowing that this team gave it their all right up to the very last second.
"Thank you, Argentina, for allowing me to fulfil the dream of becoming a world champion."
Otamendi recently joined Argentine giants River Plate after ending a successful 16-year spell in Europe, where he played for Porto, Valencia, Manchester City and Benfica.
He represented his country at four World Cups.
