Andorra's most-capped player and top goalscorer Ildefons Lima has retired to end the longest career in men's international football.

The 43-year-old defender started as captain in Andorra's 3-0 loss to Switzerland in a Euro 2024 qualifier in Sion on Tuesday and came off after 23 minutes with the game still goalless.

"The last day has arrived, 26 years since the first, 4 different decades... today, The Last Dance," Lima posted on X, formerly known as Twitter.

He made his international debut at the age of 17 and became the record holder for longest men's international career in 2022, eclipsing Welsh great Billy Meredith, whose first and last international caps were one day short of 25 years apart.

Former Brazil women's player Formiga holds the record for longest international career between 1995 and 2021.

"Congratulations to Andorra's @ildelima6 on an incredible journey, the longest international career ever!" wrote UEFA on X.

Lima is also Andorra's top scorer with 11 goals.

His 137 caps included more than 100 defeats and six wins.

Andorra played their first international in November 1996. Lima made his international debut the following June.

"It's amazing because I have all the history of our national team," Lima told the BBC in 2020.

At club level, Lima started at FC Andorra, who he rejoined last year. In between he had spells in the lower divisions in Spain, Italy and Greece and in the top flight in both Mexico and Switzerland.

Lima collects the shirts of opponents and has around 900, according to FIFA.

"If you take a shirt from 24 years ago, when the national team started, and you take a shirt from now, you can see the difference in football," he told the BBC. 

"How football has developed. I love it because it's a way to travel through the history of football."