Hamley was promoted captain in 1850, and in 1851 went to Gibraltar, where he began his literary career by contributing articles to magazines. He served throughout the Crimean campaign as aide-de-camp to Sir Richard Dacres, commanding the artillery, taking part in all the operations with distinction, and becoming successively major and lieutenant-colonel by brevet. He also received the CB and French and Turkish orders. During the war Hamley contributed to Blackwood's Magazine an admirable account of the progress of the campaign, which was afterwards republished. The combination in Hamley of literary and military ability secured for him in 1859 the professorship of military history at the new Staff College at Sandhurst, from which in 1866 he went to the council of military education, returning in 1870 to the Staff College as commandant. From 1879 to 1881 Hamley was British commissioner successively for the delimitation of the frontiers of the Ottoman Empire and Bulgaria, Ottoman Empire in Asia and the Russian Empire, and Ottoman Empire and Greece, and was rewarded with the KCMG. Promoted colonel in 1863, he became a lieutenant-general in 1882, when he commanded the 2nd division of the expedition to Egypt under Lord Wolseley, and led his troops in the Battle of Tel el-Kebir, for which he received the KCB, the thanks of Parliament, and 2nd class of the Order of Osminieh. Hamley considered that his services in Egypt had been insufficiently recognised in Lord Wolseley's despatches, and expressed his indignation freely, but he had no sufficient ground for supposing that there was any intention to belittle his services.
Hamley was a clever and versatile writer. His principal work, The Operations of War, published in 1866, became a text-book of military instruction. It was praised by the German General Helmuth von Moltke, Chief of the Prussian General Staff, and until 1894 it was the sole text used in the entrance examination for the Camberley Staff College. He also published some pamphlets on national defence, was a frequent contributor to magazines, and the author of several novels, of which perhaps the best known is Lady Lee's Widowhood. Hamley took interest in animal welfare. He authored Our Poor Relations, in 1872. The book reflected his compassion for animals and his horror of their abuse. He attacked vivisection and condemned the collecting of moths. The War in the Crimea was published in 1891 by Seeley and Co., London. Within this publication, was a complete overview of events leading up to the war in the Crimea all the way through to the close of the war.