The 34-year-old will hang up his boots for good at the end of the current campaign as he heads into an ambassadorial role with the Ospreys, but not before he gets one last opportunity to shine on the big stage with the Babaas.
Williams, who was a double try-scorer on his last appearance for the Lions in the third-Test win over the Springboks in 2009, will face his own countrymen in Cardiff in what is now already being billed as a 'mustn't-miss' encounter.
"To have a chance to finish by playing against Wales in Cardiff is an incredible opportunity and will bring my career full circle," said Williams.
"I've played for the Barbarians once before and when I was offered the chance to play this summer I had no hesitation in accepting the honour. The Barbarians is a wonderful institution and sums up everything that is good about the game of rugby.
"I've always said that I would never stay on too long and play rugby just for the sake of it. Finishing playing for Wales after the World Cup felt like the right decision, and now I've had the chance to reflect on where I'm at, it feels right that this season will be my last."
Williams will join the Barbarians ahead of their three-game tour against England at Twickenham on May 27, Ireland at Kingsholm on May 29 and then against Wales at the Millennium Stadium on June 2.