The woman in her 80s was reported missing after a home alarm triggered when she left her house in the Scottish Borders at about 9.15pm on Thursday.
Police called out the Borders Search and Rescue Unit at 1am and the team began searching the area around the woman’s home in Ayton, near Eyemouth, aided a couple of hours later by a search-and-rescue helicopter based at Prestwick, South Ayrshire.
The helicopter’s infra-red imaging system picked up heat source next to the tracks of the East Coast Main Line shortly before 4am.
The mountain rescue team contacted police to put a stop on any trains on the line and were directed to the missing woman by the helicopter.
Rescue team leader Stuart Fuller-Shapcott said: “The East Coast Main Line is very dangerous, you don’t mess around there, so I wasn’t letting my guys on the line until I had a cast-iron guarantee it was closed.
“The missing woman was just off the railway track on the ballast.
“How she had got up there is a mystery - she walked with a pair of sticks. She had cuts and bruises which she must have sustained getting up there.
“We carried her, then got her into a stretcher and moved her to safety, off the track a bit so if a train did come past we might get a fright but we weren’t going to get hit.
“We took her down the embankment, transferred her to a road ambulance and she was taken to Borders General Hospital for observation.
“I was happy enough to let police know that they could open the railway line again. It was only closed for about half an hour.
“She is very lucky. It’s a good example of joined-up working - our volunteers working with the police and air assets for a good result.”