The seven-time Ballon d'Or winner, 36, left French champions Paris St-Germain at the end of the 2022-23 season.
"I'm very excited to start this next step in my career with Inter Miami and in the United States," said Messi, who led his country as they won the World Cup in Qatar last year.
Inter Miami co-owner David Beckham said the signing was a "dream come true".
Messi, who has not previously played for a club side outside Europe, added: "This is a fantastic opportunity and together we will continue to build this beautiful project.
"The idea is to work together to achieve the objectives we set and I'm very eager to start helping here in my new home."
On securing the services of a player expected to win another Ballon d'Or this year, Beckham said: "10 years ago, when I started my journey to build a new team in Miami, I said that I dreamed of bringing the greatest players in the world to this amazing city.
"[I wanted] players who shared the ambition I had when I joined LA Galaxy, to help grow football in the USA and to build a legacy for the next generation in this sport that we love so much.
"Today that dream came true. I couldn't be prouder that a player of Leo's calibre is joining our club, but I am also delighted to welcome a good friend, an amazing person and his beautiful family to join our Inter Miami community.
"The next phase of our adventure starts her, and I can't wait to see Leo take to the pitch."
Messi will be available to play for Miami against LIGA MX side Cruz Azul on 21 July in their opening match of Leagues Cup.
"We are overjoyed that the greatest player in the world chose Inter Miami and Major League Soccer, and his decision is a testament to the momentum and energy behind our league and our sport in North America," said MLS commissioner Don Garber.
"We have no doubt that Lionel will show the world that MLS can be a league of choice for the best players in the game. We look forward to seeing his debut for Inter Miami in our Leagues Cup tournament later this month."
Messi won the last of his seven Ballon d'Or awards for the world's best player in 2021 and could win it again later this year after leading Argentina to World Cup success in Qatar in 2022.
He scored 32 goals in 75 games for PSG and ended last season with 16 goals and 16 assists in Ligue 1.
Messi joined the French side in 2021 after spending 21 years with Barcelona.
Messi is Barca's record scorer with 672 goals and won 10 La Liga titles, four Champions Leagues and seven Spanish Cups.