The British and Irish Lions will play Japan at Murrayfield on Saturday 26 June as a warm-up for their three-Test tour of South Africa.
“They are a talented side who play high-tempo rugby, so it’ll be a good challenge for us,” said Lions head coach Warren Gatland.
“It’s a chance for the matchday squad to put hands up for Test selection.”
The Lions depart for South Africa shortly afterwards, with their tour opener against the Stormers on 3 July.
The first Test against the world champion Springboks is Johannesburg’s FNB Stadium on 24 July. The venue can hold more than 90,000 spectators and was the venue for the 2010 Fifa World Cup final.
The second Test follows a week later in Cape Town before the two teams meet for a third time, back in the capital, on 7 August.
The warm-up against Japan is scheduled for the same day as the 2021 Premiership Rugby final, which precludes any of the finalists from selection.
It will be only the third time that the Lions have played on home soil.
They drew with Argentina in a similar friendly in Cardiff before the 2005 tour of New Zealand and played the Rest of the World in a fixture to celebrate the centenary of the International Rugby Football Board (now World Rugby) in 1986.
More recently tour organisers have attempted to arrange overseas warm-up matches, with the 2013 Lions playing the Barbarians in Hong Kong on a stop-off en route to Australia.
Japan reached the last eight of the Rugby World Cup on home soil in 2019, advancing from the pools at the expense of Scotland. They also scored a notable victory over South Africa in the 2015 tournament.
“It is truly a once-in-a-lifetime opportunity for our players, and we can’t wait for it to come,” said head coach Jamie Joseph.