The former Real Madrid star, who played his final match at the recent World Cup, won five Champions League trophies and made a record 111 appearances for Wales, becoming their greatest goalscorer.
Bale led his country from the international football wilderness to two European Championships - reaching the semi-finals of Euro 2016 - and a first World Cup since 1958.
The forward, who also played for Southampton, Tottenham and Los Angeles FC, said after the World Cup in Qatar he would keep going for “as long as I’m wanted” but the Cardiff-born player has now decided to hang up his boots.
“After careful and thoughtful consideration, I announce my immediate retirement from club and international football,” Bale wrote on his social media accounts.
“I feel incredibly fortunate to have realised my dream of playing the sport I love.
“It has truly given me some of the best moments of my life, the highest of highs over 17 seasons. That will be impossible to replicate, no matter what the next chapter has in store for me.”
Bale started his career at Southampton but made his name in the Premier League at Tottenham, where he was twice named players’ player of the year.
After scoring 31 goals for club and country in the 2012/13 season, it was clear that Spurs would struggle to keep Bale and Real Madrid paid a then world record fee of around £85 million (B3.4 billion) to sign him in September 2013.
The high point of Bale’s club career came in May 2018 when he scored twice in the 3-1 Champions League final victory over Liverpool, including a stunning overhead kick.
He also won three league titles in Spain but had a troubled final few years in Madrid as injuries and a perceived lack of commitment pushed him to the fringes of the first team.
The forward joined Los Angeles FC last year and went on to win the MLS Cup in early November in his short stint in the United States.
Bale started off his one and only World Cup campaign in style, scoring from the penalty spot in his country’s 1-1 draw with USA in November but defeats to Iran and England meant Wales bowed out at the group stage in Qatar.
The Wales talisman, whose 41 goals make him the top goalscorer in the country’s history, issued a separate statement to his “Welsh family”, saying his decision to retire from international football had been “by far the hardest of my career”.
“My journey on the international stage is one that has changed not only my life but who I am,” he said.
“The fortune of being Welsh and being selected to play for and captain Wales, has given me something incomparable to anything else I’ve experienced.
“I am honoured and humbled to have been able to play a part in the history of this incredible country, to have felt the support and passion of the red wall, and together have been to unexpected and amazing places.”
Real Madrid issued a statement saying they wanted to “show their appreciation, admiration and love for a legend of our club and world football”.
“He will forever be united to the history and legend of our club,” the club said.
Tottenham and Southampton congratulated Bale on an “incredible career” while LAFC also paid tribute to the star forward.
“We want to thank Gareth for everything he brought to our club,” LAFC co-president and general manager John Thorrington said. “He arrived here with a goal to win championships in LA and, like he has done everywhere else in his career, he succeeded.
“It was an honour to have one of the most talented, dynamic and exciting players of his generation finish his career with a title for LAFC.”