I remember somewhere a story about an emperor who was so convinced of his awesome powers that he attempted to command the tides to recede. All I can find on the web is the story of King Canute explaining that he lacked such power, which is the opposite of the story I remember. Does anyone know the story I remember and the name?
Perhaps you're remembering the story of King Canute and the tides? Canute was an emperor -- he had put together what's commonly called the North Sea Empire uniting England, Norway, Sweden and Denmark and indirectly controlling significant territory beyond that.
The date is just after 1000 AD, which is a long time ago, though not quite what's normally meant by 'ancient.'
The story is that his courtiers were flattering him to the point where they were telling him that even the tides obeyed his will. He had his throne taking down to the seashore and ordered the tide to stop. It didn't and he made the point that he wasn't God, but only a king.
See the Wikipedia article on Canute and the tides.
Short Answer: The question is probably asking about the story of King Canute and the tides, but may be mixing it up with stories about Xerxes and Caligula.
Long Answer Part One: Canute.
The story of King Canute and the tide is an apocryphal anecdote illustrating the piety or humility of King Canute the Great, recorded in the 12th century by Henry of Huntingdon.
In the story, Canute demonstrates to his flattering courtiers that he has no control over the elements (the incoming tide), explaining that secular power is vain compared to the supreme power of God. The episode is frequently alluded to in contexts where the futility of "trying to stop the tide" of an inexorable event is pointed out, but usually misrepresenting Canute as believing he had supernatural powers, when Huntingdon's story in fact relates the opposite.
However, Canute the Great lived from about 990 to 12 November 1035, which is not exactly ancient if that is defined as before the Middle Ages start about AD 500.
And despite what Mark Olson said in his answer:
Canute was an emperor -- he had put together what's commonly called the North Sea Empire uniting Britain, Norway, Sweden and Denmark and indirectly controlling significant territory beyond that.
Canute was not an emperor, and the so-called "North Sea Empire" was not an empire.
Nobody can be an emperor unless he claims to be an emperor, and claiming to be an emperor is not enough to make someone actually an emperor. As far as I know Canute never used the title of Emperor and so there is no need to discuss whether he did so correctly
The so-called "North Sea Empire" is just a term loosely used by modern historians to describe several different lands which were more or less independent of each other but which were in a personal union with the same king.
North Sea Empire and Anglo-Scandinavian Empire are terms used by historians to refer to the personal union of the kingdoms of England, Denmark[a] and sometimes Norway for most of the period between 1013 and 1042 towards the end of the Viking Age.1 This ephemeral Norse-ruled empire was a thalassocracy, its components only connected by and dependent upon the sea.2
The first king to unite all three kingdoms was Sweyn Forkbeard, king of Denmark since 986 and of Norway since 1000, when he conquered England in 1013. He died the following year and his realm was divided. His son Cnut the Great acquired England in 1016, Denmark in 1018 and Norway in 1028. He died in 1035 and his realm was again divided, but his successor in Denmark, Harthacnut, inherited England in 1040 and ruled it until his death. At the height of his power, when Cnut ruled all three kingdoms (1028–1035), he was the most powerful ruler in western Europe after the Holy Roman Emperor.[b]
The Latin word imperium had two meanings:
1) The authority of a Roman magistrate over the entire Roman state, or over his limited province or area of rule.
2) The entire Roman republic or empire. During the time of the Roman Empire the emperor had superior imperium over all provincial governors in the Empire, making him the governor of everywhere. Since the Romans claimed to be the rightful rulers of everywhere, the Emperor thus claimed to be the rightful ruler of everywhere.
So medieval writers could use the word imperium to mean either a province or else the entire Roman Empire.
In the time of Canute 990-1035, the only emperors were the Holy Roman Emperors, Otto III, Henry II, and Conrad II, and the eastern Roman Emperors Basil II, Constantine VIII, Romanus II, and Michael IV. In non European civilization emperor equivalents ruling empire equivalents included Abbasid Caliphs al-Qadir and al-Qa'imh, Fatamid Calips al-Hakim & Az-Zahir, and about 15 short reigning Caliphs in Spain, Huangdi's of the Liao dynasty Shengzong and Xingzong, Huangdis of the Song dynasty Zhenzong and Renzong, and maybe a few others.
In fact, at that time the kings of Denmark were usually vassals of the Holy Roman Emperors, so Canute may have been a vassal of the emperor and his kingdoms part of the Holy Roman Empire.
Long Answer Part Two: Xerxes.
When suitably enraged, the Achaemenid Persian king Xerxes I didn't limit the administration of corporal punishment to animate objects. During the second Persian invasion of Greece in 480 BC the pontoon bridges his army engineers had laid across the Dardanelles straight were destroyed by a storm. In frustration Xerxes I famously "retaliated" by having soldiers flog the very waters of the straight itself with 300 lashes!
Xerxes' Pontoon Bridges were constructed in 480 BC during the second Persian invasion of Greece upon the order of Xerxes I of Persia for the purpose of Xerxes’ army to traverse the Hellespont (the present day Dardanelles) from Asia into Thrace, then also controlled by Persia (in the European part of modern Turkey).1
The bridges were described by the ancient Greek historian Herodotus in his Histories, but little other evidence confirms Herodotus' story in this respect. Most modern historians accept the building of the bridges as such, but practically all details related by Herodotus are subject to doubt and discussion.
So the story of lashing the Hellespont as punishment might be false.
Xerxes didn't use the title of Emperor, which hadn't been invented yet. Instead his title was "The Great King, the King of Kings, the King of Lands and Peoples, the King of the World". And while great king and king of kings and king of lands and peoples are not necessarily equivalent to emperor and usually are not, King of the World (or of the Universe) is equivalent to Emperor.
In my opinion, only Roman Emperors are true emperors. But The Persian Empire under the Achaemenid dynasty was definitely an empire equivalent, making Xerxes an emperor equivalent.
Long answer Part Three: Caligula.
A famous "madness of Caligula" story told by ancient writers, including Suetonius in Lives of the Twelve Caesars, Life of Caligula, chapter 46:
Finally, as if he intended to bring the war to an end, he drew up a line of battle on the shore of the Ocean, arranging his ballistas80 and other artillery; and when no one knew or could imagine what he was going to do, he suddenly bade them gather shells and fill their helmets and the folds of their gowns, calling them "spoils from the Ocean, due to the Capitol and Palatine." As a monument p477 of his victory he erected a lofty tower, from which lights were to shine at night to guide the course of ships, as from the Pharos.81 Then promising the soldiers a gratuity of a hundred denarii each, as if he had shown unprecedented liberality, he said, "Go your way happy; go your way rich."
That is a very strange story and nobody knows how true it is. The lighthouse could have been built to assist peaceful trade with Britain and/or to guide ships during a planned invasion of Britain.
And possibly gathering shells from the seashore could be considered punishing the English Channel for standing between Caligula and his alleged planned invasion of Britain.
There seems to have been a northern campaign to Britannia that was aborted. This campaign is derided by ancient historians with accounts of Gauls dressed up as Germanic tribesmen at his triumph and Roman troops ordered to collect seashells as "spoils of the sea". The few primary sources disagree on what precisely occurred. Modern historians have put forward numerous theories in an attempt to explain these actions. This trip to the English Channel could have merely been a training and scouting mission. The mission may have been to accept the surrender of the British chieftain Adminius.
Another "madness of Caligula" story told by ancient writers, including Suetonius in chapter 19:
Besides this, he devised a novel and unheard of kind of pageant; for he bridged the gap between Baiae and the mole at Puteoli, a distance of about thirty-six hundred paces,29 by bringing together merchant ships from all sides and anchoring them in a double line, afterwards a mound of earth was heaped upon them and fashioned in the manner of the Appian Way. 2 Over this bridge he rode back and forth for two successive days, the first day on a p433 caparisoned horse, himself resplendent in a crown of oak leaves, a buckler, a sword, and a cloak of cloth of gold; on the second, in the dress of a charioteer in a car drawn by a pair of famous horses, carrying before him a boy named Dareus, one of the hostages from Parthia, and attended by the entire praetorian guard and a company of his friends in Gallic chariots. 3 I know that many have supposed that Gaius devised this kind of bridge in rivalry of Xerxes, who excited no little admiration by bridging the much narrower Hellespont; others, that it was to inspire fear in Germany and Britain, on which he had designs, by the fame of some stupendous work. But when I was a boy, I used to hear my grandfather say that the reason for the work, as revealed by the emperor's confidential courtiers, was that Thrasyllus the astrologer had declared to Tiberius, when he was worried about his successor and inclined towards his natural grandson,30 that Gaius had no more chance of becoming emperor than of riding about over the gulf of Baiae with horses.
This story could also be interpreted as Caligula insanely claiming rule over the oceans by those who want to depict him as being insane.
To sum up, user3794648 probably remembers the story of Canute and the tides, possibly mixed with stories about Xerxes and Caligula.
According to Kim Ryholt Sobekhotep VIII was likely an upper Egyptian pharoah during the 16th dynasty.
Sekhemre Seusertawy Sobekhotep VIII was possibly the third king of the 16th Dynasty of Egypt reigning over the Theban region in Upper Egypt during the Second Intermediate Period.1
Also, according to "John Baines", Sobekhotep VIII served during a Nile flooding (inundation) and he waded through the waters and ordered the waters to recede.
Apparently he was reenacting the Egyptian story of Amun-Ra.
According to Egyptologist John Baines, who studied the stela in detail, by coming to the temple as it was flooded, the king reenacted the Egyptian story of the creation of the world in imitating the actions of the creator god Amun-Ra, to which the stela iconography closely associates the king, ordering the waters to recede from around the primordial mount.4
Which emperor tried to command the tides?
As you have already stated in your question description that you do not believe it to be king Canute, I have tried to find someone a little more ancient, and though I do not know if this is the emperor in question, the only king with any historical credence that I can think of that had a claim of ordering waters to recede, was Egyptian pharoah Sobekhotep VIII.
This is not to say that the waters receded because they were ordered to. The flooding was part of the yearly monsoon and is known as the "the martyr's finger". It is celebrated for two weeks every year.
The flooding of the Nile has been an important natural cycle in Egypt since ancient times. It is celebrated by Egyptians as an annual holiday for two weeks starting August 15, known as Wafaa El-Nil. It is also celebrated in the Coptic Church by ceremonially throwing a martyr's relic into the river, hence the name, The Martyr's Finger (Coptic: ⲡⲓⲧⲏⲃ ⲛⲙⲁⲣⲧⲏⲣⲟⲥ, Arabic: Esba` al-shahīd). Ancient Egyptians believed that the Nile flooded every year because of Isis's tears of sorrow for her dead husband, Osiris.