Edinburgh recorded its hottest day on Thursday at 31.6C as the heatwave toppled records across northern Europe.
However, cooler weather is forecast, with an overnight threat of thundery downpours followed by further heavy rain over the weekend.
The Met Office said the new record was set at Gogarburn, 0.2C higher than the previous high at Edinburgh Airport in 1975.
The capital also had the highest temperature in Scotland, with 31C at Kinloss in Moray.
It remains some way off the Scottish record of 32.9C, in the Borders in 2003.
But the heat caused major disruption on both main rail lines between Scotland and London, with east coast operator LNER cancelling all trains last night in and out of King’s Cross.
The firm said there was a “controlled evacuation” of one Edinburgh-London service near Peterborough.
All lines were blocked because of damage to overhead power lines.
A passenger tweeted that staff were treating children with symptoms of heatstroke on another Edinburgh-London train.
A spokesperson for LNER said: “Services were disrupted today due to record-breaking high temperatures, followed by damage to the overhead lines late this afternoon. This halted services while power was turned off and emergency repairs could be carried out.
“A controlled evacuation was carried out on one of our trains at Peterborough to another train.
“We appreciate conditions on the train were very uncomfortable for those on-board. Our train crew and station teams along were on-hand with medical support for anyone requiring extra assistance. We apologise to all of our customers who have had their journeys disrupted today.”
On the Glasgow-London west coast main line, Virgin Trains said some lines were blocked between Watford and Euston, also by overhead line damage.
There were also problems on the line further north, between Carlisle and Preston.
In Scotland, heat-related power losses to the overhead wires near Bathgate seriously disrupted Edinburgh-Glasgow trains via Airdrie.
Trains were slowed to 20mph at 12 places across Ayrshire and Argyll to prevent tracks from buckling in the heat.
A new UK July record of 38.1C was set in Cambridge, outstripping 36.7C at Heathrow in 2015, and making it the second hottest day on record.
But the overall record of 38.5C remained unbeaten, despite forecasts the temperature could reach 39C.
The Met Office said high pressure over eastern Europe and Scandinavia, combined with the position of the jet stream was funnelling hot air from Europe which had originated in north Africa.
However, it said there was “no doubt” climate change is playing a role in the intensity of the heat being witnessed.
Despite the heat, flood alerts were issued for the Scottish mainland away from the west coast by the Scottish Environment Protection Agency because of the risk of heavy downpours overnight.
Night-time temperatures were not expected to fall below about 19C in the Central Belt.
A yellow - “be aware” - severe weather warning was in force for the eastern half of Scotland until 4am today.
That will be followed by a similar warning for downpours and possible flooding in southern Scotland south of the Central Belt from noon tomorrow until 3pm on Sunday.
In Europe, temperature records tumbled for a second day, with the Netherlands setting a new high of 40.7C and Belgium of 40.6C.
A new record in Germany of 42.6C was also set.