Murray served as Quartermaster General in India from 1801 to 1805. There, "his alternations of torpor and feverish activity had greatly embarrassed the young Arthur Wellesley with whom he was supposed to be cooperating." He married Anne Elizabeth Cholmley Phipps on 25 August 1807.
Peninsula
During the Second Battle of Porto in 1809, Major General Murray commanded the 7th Brigade, the largest brigade in Wellington's army. This 2,900-strong unit included the 1st, 2nd, 5th and 7th King's German Legion Infantry battalions, plus elements of the 1st and 2nd KGL Light Infantry. After giving Murray two additional cavalry squadrons, Wellington entrusted him with the task of crossing the Douro River and cutting off the escape route of Marshal Nicolas Soult's French corps. Accordingly, Murray crossed the Douro at a ferry east of Porto and moved north. However, he failed to seriously contest the French retreat to the northeast. Instead, he skirmished ineffectually with the enemy. Michael Glover, historian of the Peninsular War, calls Murray "a stupid and irresolute officer." He soon left Portugal because he feared he would have to serve under William Beresford, 1st Viscount Beresford, who was a marshal of the Portuguese Army. Beresford was junior to Murray in British rank, but as a marshal would outrank him in the field. He became 8th Baronet Murray of Dunerne in 1811. On 31July 1812, an 8,000-man Anglo-Sicilian force under Thomas Maitland landed at Alicante on the Mediterranean coast of Spain. It then went through a succession of commanders until February 1813, when Murray, now a lieutenant-general, took command. By this time, the force was 10,000 men strong. Of these, 3,000 were Sicilians and Italians, while the rest were British and KGL troops. Two Spanish divisions, 8,000 men, also came under his orders. With his 18,200-man army, Murray defeated Marshal Louis Suchet at the Battle of Castalla on 13April 1813. Though Suchet's 13,200 were considerably outnumbered and the battle was largely won by the steadiness of the British and Spanish infantry, Castalla was undoubtedly Murray's finest hour. But he did not pursue the beaten French, continuing his withdrawal to the coast.
Soon after, Wellington ordered Murray to move by sea to capture the port of Tarragona. By this maneuver, Wellington intended to distract Suchet from his summer offensive. Rear-Admiral Benjamin Hallowell Carew put Murray's 16,000 men ashore six miles south of Tarragona on 2 June. Joined by Spanish Major-Geneneral Francisco Copons with 7,000 men, the Allies quickly invested the 1,600-man Franco-Italian garrison of Brigadier-General Bertoletti. Thus began the Siege of Tarragona's comedy of errors. Bertoletti quickly pulled most of his men into the inner defenses, leaving token garrisons in two outworks. Rather than storm these, Murray chose to reduce them by siege. By 7 June, his siege guns had reduced one of the two forts to rubble. Meanwhile, Major-General Charles Decaen sent Major-General Maurice Mathieu with 6,000 men south from Barcelona to interfere with the siege. At the same time, Suchet marched 8,000 men north from Valencia toward Tarragona. Soon, a Spanish move against Valencia caused the southern column to be recalled. Mathieu bumped into Copons' pickets, found that he was facing a combined force of 23,000 men and quickly backpedaled. By this time, Murray had been driven into a state of panic by rumors of the two French relief columns. He cancelled a planned 11 June attack on the small outwork and ordered his supplies to be taken aboard ship. Later, he decided to withdraw his entire force. Issuing a stream of orders that confused everyone and enraged Hallowell, Murray finally got his entire force aboard ship after spiking and abandoning the eighteen heavy siege cannons. Copons was advised to flee to the mountains. Once safely aboard, Murray determined to land at a different place on 15 June. Soon, confusion again reigned. In despair, Hallowell wrote, "the debarkation and the re-embarkation continually going on was enough to confound any operation in the world." Mathieu finally marched into Tarragona on 16 June. The appearance of these fresh troops caused Murray to give up his plans again, and his thwarted expedition returned to Alicante. He was relieved of command on 18 June.
Later career
After the war ended in 1814, Murray was court-martialed for his conduct before Tarragona. The court acquitted him of all charges except one: he was found guilty of abandoning his guns without due cause and admonished by the court. Acting as though he was cleared of all charges, Murray petitioned to become a member of the Order of the Bath, but was denied. He was Member of Parliament for Weymouth and Melcombe Regis from 1811 to 1818. Murray died on 15 October 1827.