Barnard was born at Fahan, County Donegal, Ireland. He was the son of the Rev. Dr. Henry Barnard, of Bovagh, County Londonderry (second son of William Barnard, Bishop of Derry, and brother of Thomas Barnard, Bishop of Limerick), by his second wife, Sarah neé Robertson of Bannbrook, County Londonderry.
He entered the army in Scotland as an ensign in the 90th Regiment of Foot in August, 1794, became a lieutenant in the 81st Regiment of Foot in September and a captain in November of the same year. He served in St. Domingo from April till August, 1795, and on 2 December was transferred to the 55th Regiment.
He served in the expedition to the West Indies under Sir Ralph Abercromby, and was present at the reduction of Morne Fortune in May, 1796.
In 1799 he accompanied the Helder Expedition, and was present at the actions of 27 August, 10 September, and 2 and 6 October.
On 19 December he was gazetted lieutenant and captain in the 1st Regiment of Footguards (now the Grenadier Guards), obtained the rank of Major on 1 January 1805, embarked with the 1st brigade of guards for Sicily in 1806, and returned to England in September, 1807.
On 28 January 1808 he became a lieutenant-colonel in the army, and was appointed Inspecting Field Officer of Militia in North America. He embarked for Canada in July 1808, was gazetted into the 1st Royals on 18 December, and returned to England in August 1809.
On 29 March 1810 he exchanged into the 95th Rifles and with the glories of that distinguished regiment his name was henceforth linked. He was appointed to the command of the 3rd battalion, which had lately been raised, and on 11 July 1810 he embarked with the headquarters and two companies in the frigate HMS Mercury, and landed on the 29th at Cadiz, which was then besieged by Marshal Victor. He commanded his battalion at the Battle of Barrosa, where he was wounded twice, once severely; was present at the sieges of Ciudad Rodrigo and Badajoz (1812), and at the battles of Salamanca and Vittoria. Soon after the capture of Badajoz he was transferred to the 1st battalion. He obtained the rank of colonel on 4 June 1813; was at the storming of San Sebastián, at the passage of the Nivelle, where he was again severely wounded — shot through the lung — and at the battles of Orthez and Toulouse. In July, 1813 we find him a Knight Commander of the Bath. On 16 February 1814 Sir Andrew Barnard was appointed to the command of the 2nd brigade (the 52nd and 1st Battalion 95th) of the celebrated light division. For his services in Spain and Portugal he received a gold cross and four clasps.
On the resumption of hostilities against Napoleon in 1815, Sir Andrew embarked with six companies of the 1st battalion of the 95th at Dover on 25 April, landed at Ostend on the 27th, and arrived at Brussels on 12 May. He was present at battle of Quatre Bras, and was slightly wounded at Waterloo. For his services in this campaign he was awarded the Russian order of St. George and the Austrian Military Order of Maria Theresa. The Duke of Wellington had so high an opinion of his services that, on the capitulation of Paris, he appointed him commandant of the British division occupying the French capital.
In 1821 King George IV appointed him a groom of the bedchamber, and on 13 June 1828 promoted him equerry to His Majesty. On 4 June 1830 he was gazetted one of three ‘commissioners for affixing His Majesty's signature to instruments requiring the same’ (London Gazette, 4 June 1830). On the accession of William IV he became clerk-marshal in the royal household, and for many years, until the death of her majesty, he was clerk-marshal to Queen Adelaide.
Sir Andrew became a major-general on 12 August 1819, and on 25 August 1822 Colonel of the Rifle Brigade. He was gazetted a lieutenant-general on 10 January 1837. On 26 November 1849 the Duke of Wellington appointed him lieutenant-governor of Chelsea Hospital, and on 11 November 1851 he obtained the full rank of general.
He had the honorary dignity of M.A. conferred on him by the university of Cambridge in 1842, and was a governor of the Royal Academy of Music, of which institution he was one of the early promoters. He was nominated Knight of the Hanoverian Guelphic order in 1819 and a grand cross in 1833, and a Knight Grand Cross of the Bath in 1840.
He died at Chelsea on 17 January 1855. Prior to the funeral those of the pensioners who had served under him in the Peninsula obtained permission to see his remains. After they had left the room it was found that the coffin was covered with laurel leaves, for each man, unobserved, had brought in one and laid it on the body of his venerated chief.