The game will provide a much-needed financial boost for Scottish Rugby which is set to be hit hard by the likely absence of supporters from the autumn Tests.
It is the first time that the sides have met and they will play for the Vodafone Lions 1888 Cup in Edinburgh on Saturday June 26.
Organisers are confident that fans will be allowed to attend and tickets for the fixture will go on pre-sale on Tuesday November 3, with supporters able to register their interest from today.
The Lions, under the leadership of head coach Warren Gatland, will play a three-Test series against the Springboks next summer.
“One of our objectives is to give Warren and the playing squad as much meaningful preparation as possible before departing on tour, so we are delighted to have agreed this fixture,” said Ben Calveley, managing director of the British and Irish Lions.
“A Lions Test is one of the most iconic events in world sport, but a huge number of fans from the Home Nations never get the chance to see one live. The Vodafone Lions 1888 Cup match will give even more supporters the opportunity to be part of the next chapter in Lions history.
“It will be an ‘I was there’ moment, against an entertaining and highly-respected opposition.”
Gatland believes the 2019 Rugby World Cup quarter-finalists will provide a stern test for his squad before they depart for South Africa to take on the world champions.
“We saw Japan play some excellent rugby during the World Cup and they will come to Edinburgh fully motivated to win,” said Gatland.
“They are a talented side who play high-tempo rugby, so it’ll be a good challenge for us ahead of the Tour and a chance for the matchday squad to put their hands up for Test selection.”
The 67,000-capacity Murrayfield will be playing host to what is only the third Lions Test match on ‘home’ soil, following games in Cardiff against Argentina in 2005 and against a Rest of the World XV in 1986.
Mark Dodson, chief executive of Scottish Rugby and Lions board director, said: “We are very proud to be welcoming the Lions and Japan to the home of Scottish Rugby next June.
“BT Murrayfield Stadium has a long history of hosting major sporting events and is renowned among rugby fans as one of the iconic stadiums in the world game.
“The deep connection Scotland enjoys with the British and Irish Lions has helped to shape the rich history of the team with players, coaches and support staff all contributing to the success of the side down the years.”
The Lions’ eight-game tour to South Africa kicks off on Saturday July 3 when they play Stormers in Cape Town. It is one of five matches they will play before the first Test in Johannesburg on July 24. The second Test is on July 31 in Cape Town before the series ends with the third Test in Gauteng on August 7.