European champions Liverpool will take on Napoli in a friendly at Murrayfield on 28 July.
Scotland captain Andy Robertson’s club side will play at the home of Scottish rugby for the first time.
The Edinburgh ground has been used to host football in recent years, including the League Cup semi-final between Celtic and Hearts in October.
“We are delighted to be able to host this world-class match,” said Scottish Rugby chief executive Dominic McKay.
“This match is a unique opportunity to see international club football in Scotland this summer, a treat for any sports fans. The Edinburgh International Festival begins a few days after this fixture so this will add to an already exciting time in the capital city.”
Barcelona played at Murrayfield in 2007 and 2008 and Celtic played two European ties at the ground in 2014 while Celtic Park was unavailable.