Military Academy at Woolwich on 15 June 1801, and received a commission as second lieutenant in the royal engineers on 1 Oct. 1802. On the 9th of the same month he was promoted to be first lieutenant. He was sent to the south-eastern military district, and was employed on the defences of the south coast of Kent.
On 16 Dec. 1804 he embarked for the West Indies, where he served under Sir Charles Shipley [q. v.], the commanding royal engineer. He was promoted to be second captain on 18 Nov. 1807. In December 1807 he accompanied the expedition under General Bowyer from Barbados against the Danish West India Islands, and took part under Shipley in the operations which resulted in the capture of St. Thomas, St. John, and Santa Cruz. In January 1809 he accompanied the expedition under Sir George Beckwith to attack Martinique, and took part under Shipley in the attack on, and capture of, Pigeon Island on 4 Feb., and in the siege and capture of Fort Bourbon, which led to the capitulation of the whole island on 23 Feb. He was severely wounded on this occasion, and on his return to England on 31 March 1810 he received a pension of 100l. per annum for his wounds.
On 25 Oct. of the same year Smith embarked for the Peninsula, and joined the force of Sir Thomas Graham at Cadiz, then blockaded by the French. In the spring of 1811 an attempt to raise the siege was made by sending a force by water to Tarifa to march on the flank of the enemy, while at the same time a sortie was made by the garrison of Cadiz and La Isla across the river San Pedro. Smith was left in Cadiz as senior engineer officer in charge of it, as well as of La Isla and the adjacent country, during the operations which comprised the battle of Barossa (5 March 1811). In spite of this victory the siege was not raised, and the British retired within the lines of La Isla.
Smith's health suffered a good deal at Cadiz, and he was sent to Tarifa, near Gibraltar, where he was commanding royal engineer during the siege by the French, eight thousand strong, under General Laval. Colonel Skerrett commanded the garrison, which was made up of drafts from regiments at Gibraltar and Spanish details, numbering some 2,300 men. The outposts were driven in on 19 Dec., and in ten days the French batteries opened fire. During this time Smith was busy making such preparations as he could for the defence of a very weak place. When, however, a gaping breach was made by the French after a few hours' firing, Skerrett called a council of war, proposed to abandon the defence, to embark the garrison on board the transports lying in the roadstead, and to sail for Gibraltar. Smith vehemently opposed the proposal, and prepared to make the most desperate resistance. Intimation of the state of affairs was sent to the governor of Gibraltar, who promptly removed the transports and so compelled Skerrett to hold out. He also arranged to send assistance from Gibraltar. On 31 Dec. 1811 the French made an unsuccessful assault. Bad weather and a continuous downpour of rain greatly damaged the French batteries and trenches, and supply became difficult owing to the state of the roads. On the night of 4 Jan. 1812 it became known to the garrison that the French were preparing to raise the siege, and on the morning of the 5th the allies assumed the offensive, drove the French from their batteries and trenches, and compelled them to make a hurried retreat, leaving everything in the hands of the garrison. By general consent the chief merit of the defence has been given to Smith. Napier, in his ‘History of the War in the Peninsula’ (iv. 59, 60), points out that though Skerrett eventually yielded to Smith's energy, he did it with reluctance, and constantly during the siege impeded the works by calling off the labourers to prepare posts of retreat. ‘To the British engineer, therefore, belongs the praise of this splendid action.’
Smith was promoted for his services at Tarifa to be brevet major, to date from 31 Dec. 1811. He was promoted to be first captain in the royal engineers on 12 April 1812, and returned to Cadiz, where he was commanding royal engineer until the siege was raised in July of that year. In the following year he took part in the action of Osma (18 June 1813), the battle of Vittoria (21 June), and the engagements at Villa Franca and Tolosa (24 and 25 June), when he had a horse shot under him. He accompanied Sir Thomas Graham on 1 July to take part in the siege of San Sebastian. On the visit of the Duke of Wellington on the 12th, he attended him round the positions as senior officer (for the time being) of royal engineers, and his proposed plans of operation met with Wellington's approval. The place fell on 9 Sept., and, having been mentioned in Graham's despatch, Smith was promoted to be brevet lieutenant-colonel on 21 Sept. 1813 ‘for conduct before the enemy at San Sebastian.’
Smith arrived in Belgium and Holland from the south of France in July 1814, and reached England in August. He was knighted by the prince regent on 10 Nov., and on the same date he received permission to