The incident happened on June 23, about 40 miles north of Glasgow, as both crews followed each others' instructions instead.
At one point during the incident the two Boeing 747s were just 3.9 nautical miles apart horizontally and 100ft apart vertically.
Details of the were revealed in a report by the UK Airprox Board which examines near-misses in British airspace.
At the time of the incident both planes were in airspace under the command of air traffic controllers in Prestwick.
The report noted that one of the 747s requested to climb to an "oceanic level" height. It was allowed to do so but this resulted in a "potential confliction" with another 747 which was "on a converging track".
But the controllers, realising there was "the potential for conflict", took action by issuing appropriate avoiding instructions to both aircraft. The Airprox Board concluded that the pilots did not follow all instructions.
The report stated: "It was apparent that both crews had taken each others' instructions, and the board found it hard to determine why this had occurred; unfortunately no human factor report was available from either crew.
"The board was surprised that all four pilots had misheard or misinterpreted the avoiding action instructions despite at least one of the crews reading them back correctly."
The board added that it is possible that the crews may have been distracted.