The Greek historian Thucydides was probably the first to notice this ability.
He described how, days before a cataclysmic earthquake flattened the city of Helice, dogs abandoned the place in their droves. Thucydides was convinced the dogs knew what was coming and had run for their lives.
This has been borne out by scientific studies. One American study found that 17 out of 50 homes near the scene of a Californian quake in 1977 reported odd behaviour in their animals. Evidence ranged from a dog pacing around and fidgeting during its normal nap time to a normally placid dog whining excitedly. Studies in the Mojave desert in the US also found that dogs barked at small aftershocks unnoticed by humans but picked up by seismometers.
The most convincing recent evidence of this came before the Asian Tsunami struck on December 26th, 2004. In the hours before the tsunami many dogs refused to go for their daily walks near the sea. Many dogs were also seen running for higher ground minutes before the lethal tidal wave struck land killing thousands of people, who - unlike their pets - had been oblivious to the threat they faced.
For more odd and interesting scientific facts about man’s best friend you should read ‘Play It Again Tom: Curious Truths About Cats And Dogs’ by Augustus Brown.