Prime Minister Boris Johnson has said the fatal train derailment in Aberdeenshire must “never happen again” as he joined Scottish First Minister Nicola Sturgeon in paying tribute to the victims.

The PM also called for a probe into the impact of “substantial rainfall on vulnerable infrastructure” amid fears the crash, which killed three people, was caused by a landslip due to torrential rain.

Ms Sturgeon described the incident as “tragic” and thanked the emergency services for their efforts.

Speaking to Sky News, Mr Johnson said: “One of the reasons that this accident is so shocking is of course that this type of accident on our railways is thankfully so rare.

“But our thoughts are very much with those who’ve lost their lives, their families and of course those who’ve been injured in the derailment.

“I’ve talked to First Minister Nicola Sturgeon about what has happened and clearly the most important thing now is that the British Transport Police, who are in charge of the investigation, find out exactly what happened, and that we all work together with Network Rail, with everybody else who’s responsible to make sure that nothing like this happens again.”

He added: “As I understand there was about a month’s worth of rainfall in a very short period which undoubtedly aggravated the problem there.

“But I think what we’ll have to do is wait and see what the British Transport Police come up with, what exactly they identify as the cause of this derailment and working with Network Rail, with everybody, make sure that nothing like this happens again.”

Writing on Twitter, Ms Sturgeon said: “My deepest condolences are with the loved ones of those who lost their lives in this tragic incident.

“I have just been updated by Network Rail and the emergency services on the ongoing operation. My thanks go to them, and my thoughts remain with everyone affected.”

Transport Secretary Grant Shapps said his department was on hand to provide any support needed to the Scottish Government, adding lessons would be learned from the incident.

He said: “The safety of passengers and staff is and has always been our upmost priority and we will ensure that lessons are learned from this tragic incident once the Rail Accident Investigation Branch has carried out its investigation.”

Alister Jack, the Secretary of State for Scotland, said he wished a speedy recovery to the six people taken to hospital from the scene in Aberdeenshire.

“My heart goes out to the families and friends of those who have sadly died… and I wish those taken to hospital a speedy recovery,” he said in a statement.

“Our emergency services deserve enormous credit for their handling of this major incident and we now must wait for the results of the investigation.”

In a written statement Kevin Lindsay, the Scottish organiser for train driver’s union the Associated Society of Locomotive Engineers and Firemen (ASLEF), said “torrential rain” may have been a cause for the crash.

“While it is too early to speculate… it would seem that the appalling weather conditions in the area – the torrential rain – resulted in a landslip which, in turn, caused the train to derail,” said Mr Lindsay.