Lance Corporal Christopher Roney, whose base with the 3rd Battalion The Rifles was at Dreghorn in Edinburgh, died from head injuries he suffered while serving at Patrol Base Almas, in Sangin, Helmand.
The inquest heard the Americans were acting on information passed to them by the British Army.
The base had been rocked at night by a Taliban bomb and the platoon based there was fighting off an attack when two US gunships were called in to help.
But they fired on the base – despite the flagpole, machine gun, and men in uniform – thinking it was an enemy position.
Warrant Officer John Pepper was in an operations room some distance away where he was handling information coming in from battlegroup members.
He watched one strafing run on a video link, then Captain Christopher Dadd became aware of the reality of the situation.
WO Pepper said: "Capt Dadd shouted, 'Stop, stop, stop.' That was when everyone in the ops room realised they were attacking Patrol Base Almas. He had his head in his hands."
At the inquest, Coroner Derek Winter heard how British commanders asked for the Apaches to assist, and grid references were passed on.
In December 2009, the Apaches were directed to a compound and told to look for three men on a roof who were believed to be insurgents but were in fact British soldiers fighting off the Taliban, the inquest heard.
Apache helicopters, which had the call-signs Luger 67 and Luger 61, were involved. The crews were authorised to fire and Luger 67 passed over the compound twice as Luger 61 covered.
It was seven minutes after the first pass that the mistake was realised.
At one point Luger 61 asked to fire off a missile, but permission was denied, the inquest heard.
The coroner had heard that a total of 200 rounds were fired, leaving seven men badly injured. L/Cpl Roney died the next day.
At Patrol Base Almas, Captain Palmer Winstanley, who led the platoon, wept when he contacted the operations room to tell them to call off the Apaches, the inquest heard.
Lance Corporal Johnny Cassell told the hearing: "It seemed like he was in tears, saying, 'Stop the Apaches, stop the Apaches.'"
Once the Apaches were called off, leaving 11 men injured on the ground, an air strike was called in on the enemy position and a 500lb bomb brought a halt to the Taliban attack.
Major Timothy Harris told the inquest how commanders saw the Taliban attack – which followed a serious raid on Almas two nights before – as a chance to hit back, though he did not think there was a "gung ho" attitude.
The hearing, which was adjourned, continues today.