The CIS Insurance Cup semi-final draw descended into farce tonight.
A procedural error emerged hours after the clubs were told who they would face in the matches next January.
The draw at the Scottish Parliament was made by Scotland's First Minister Alex Salmond and a representative of the sponsors, in the company of Presiding Officer Alex Fergusson.
However an apparent bungle concerning the numbers for the teams meant they were told the wrong opponents
Rangers, who were initially told they would face Aberdeen, will instead take on Hearts.
And Dundee United will now be Aberdeen's opponents.
It was Fergusson who made the error which did not come to light in the immediate aftermath of the draw.
The teams were allocated numbers based on their final league positions last season, with Rangers ball one for the draw, Aberdeen ball two, Hearts ball three and Dundee United ball four.
But rather than call the four-ball draw correctly, it transpired Fergusson had made an elementary mistake by announcing the wrong teams.
Tonight the MSP revealed his regret.
'This was a genuine error and I can only apologise for the confusion caused,' Fergusson said.
'We have worked as quickly as possible with the Scottish Football League to resolve the situation.
'As a lifelong Stranraer fan I think everyone can be assured that there was no ulterior motive.'
SFL chief executive David Longmuir insisted the draw had to be altered, despite representatives from all the clubs present in Edinburgh having already discussed the semi-final ties at length with the media.
Longmuir said: 'The Scottish Football League has a duty to the teams involved to correct the error and to protect the integrity of the draw.
'The four clubs involved have all been informed of the error and the correct draw.'
The Rangers versus Hearts match will be played at Hampden, and the other tie could be staged at Easter Road.
The ties will be played on January 29 and 30, although it has not yet been confirmed which matches will take place on which night.
SFL president Brown McMaster insists preserving the integrity of the draw was more important than any embarrassment.
He told STV: 'We found out quite quickly, then we had to work out how to unravel it.
'The important thing is that maybe it's an embarrassment but I would rather have an embarrassment than a lack of integrity.
'We insisted that it had to be changed but we got co-operation from the Scottish government and CIS.
'It was important to us that the way the draw was made was the way the games are to be played.
'People know how we do our seeding systems so it would have been known to a lot of people that number two would have been Aberdeen because they did finish above Hearts in the league last year.
'It's unfortunate. It's an error, the presiding officer has apologised for it and the integrity has remained intact.
'It would have been more embarrassing if we had left it. It would have come out so I think we did the right thing, we moved as quickly as we could.
'It's not an ideal scenario but it was a genuine mistake and the man who made the mistake has apologised profusely.
'I think everyone is happy with the final outcome.'