Operations Control mobilised a number of fire engines to Arniston Farm near Tranent in East Lothian after the alarm was raised at 7.50pm on Wednesday, October 17.
Crews worked for more than 12 hours to contain the fire to the hay bales and protect nearby properties. The fire was thereafter extinguished.
Firefighters remained in attendance to ensure the area was made safe before leaving the scene at 11.55am on Thursday, October 18.
Steve Gourlay is the Scottish Fire and Rescue Service’s Local Senior Officer for East Lothian.
He said: “The fire was certainly spectacular and could be seen for many miles with black smoke visible down the coast.
“Firefighters worked hard throughout the night to contain the flames, prevent the fire spreading to nearby properties and protect the community.
“Unfortunately this had some impact on the farm, but my thanks goes to the crews and to our partners for bringing this incident to a safe conclusion.”