Lyall was born in London on March 9, 1845 and educated at King's College London and Balliol College, Oxford. He joined the Bengal Civil Service in 1867 and rose to be a distinguished administrator, becoming, successively, secretary to the Home Department of the Government of India in 1889, Chief Commissioner of Assam in 1894 and of the Central Provinces and Berar from 1895 to 1898. He presided over the Famine Commission of 1898, which was instituted after the Indian famine of 1896–97 which was particularly devastating in the Central Provinces. In 1898, he was transferred to the India Office in London as secretary to the Judicial and Public Department, a post that he held until his retirement in 1910.
The city of Faisalabad in Pakistan (then part of British India) was originally known as Lyallpur (literally Lyalltown), being named after Lyall during his tenure as Lieutenant Governor. The municipal area, Lyallpur Town, retains the name.
In his time, however, Lyall was better known as a scholar of Arabic poetry. He published the two-volume Translations of Ancient Arabian Poetry (1885, 1894), and translations of The Diwan of Abid ibn al-Abras (1913), The Poems of Amr Son of Qamiah (1919), and The Mufaddaliyat (1921), as well as articles on Hindustani and Arabic literature
He was knighted with the K.C.S.I. in 1897, and was elected a Fellow of the British Academy; he also received honorary degrees from the universities of Oxford, Edinburgh and Strasbourg. He died in London September 2, 1920.