The significant part of Hartley's career begins with the
First Anglo-Maratha War. In February 1775 he was sent to co-operate with Colonel
Keating in
Gujarat. But the supreme government of the
British East India Company in
Calcutta put an end to the war in the following August (see
Treaty of Purandar (1776), and Hartley, with the rest of the British forces, returned to Bombay. Three years later hostilities were resumed. The Bombay government now sent an army to the
Konkan, with orders to march across the
Western Ghauts on
Poonah. An advanced party of six companies of
grenadier sepoys under Captain Stewart first took possession of the
Bhore Ghaut, where they were joined by the main army under Colonel
Charles Egerton. Hartley had been offered the post of quartermaster general to the army, but he preferred to take his place at the head of his battalion. On 4 January 1779, Captain Stewart, a man of conspicuous gallantry, was killed in a skirmish at
Karli, and Hartley was appointed to succeed him in command of the six companies of grenadiers. On 9 Jan. the British army continued their march, and reached
Tullygaom, only eighteen miles from
Poonah. But
John Carnac, the civil commissioner with the army, became alarmed at the increasing numbers of the
Mahrattas, and determined on a retreat. Hartley strongly resisted this proposal, but was overruled, and the retreat began on 11 Jan. Hartley's reserve was directed to form the rear guard. At daybreak on 12 Jan. the Mahrattas assailed the retreating army in strong force. The main energy of their attack was directed on the rear. The sepoys were thoroughly demoralized, and it was only by means of a personal address from Hartley that they were hindered from wholesale desertions. But, in spite of the condition of his own men and the superior numbers of the enemy, Hartley sustained the conflict with such skill that the army was able to make good its entry into
Wargaum. Hartley in vain protested against the
Convention of Wargaum, by which the British, in return for the surrender of their ally,
Raghoba, were allowed to retire unmolested. On his arrival at Bombay in the spring of 1779, Hartley was universally regarded as having saved the British army from annihilation. He was raised to the rank of lieutenant-colonel, and was appointed to the command of the European infantry on the Bombay establishment. In December 1779, Hartley was sent with a small detachment to act under Colonel
Thomas Goddard to
Guzerat. He led the storming party which captured
Ahmedabad on 18 February ensuing. On 8 May, however, he was recalled to Bombay, and entrusted with the duty of securing the
Konkan, i.e. the district between the Western Ghauts and the sea, from which the Bombay government drew their supplies. On 24 May he defeated and dispersed a party of Mahrattas who had besieged the fortified post of
Kallian to the northeast of Bombay. On 1 October another attack of the enemy from the same direction was crushed at
Mullungurh; the
Bhore Ghaut, a central point of the mountain-chain, exactly opposite Bombay, was strongly guarded, and the Konkan effectually secured to the British. In November Goddard, in deference to the wishes of the
Bombay Presidency, embarked on the siege of Bassein (now
Vasai). Hartley, with about two thousand men, was directed to maintain a position on the east, and so prevent the Mahrattas from raising the siege. On 10 December, a determined attack was made on Hartley's entrenchments at
Doogaur by twenty thousand Mahrattas. After a severe conflict, the assailants were repulsed and the garrison of Bassein surrendered. ==Check to Hartley's career, Royal intervention==