The James Tait Black Memorial awards are given to one work of fiction and one work of biography each year.
Former winners of the £10,000 prize, announced by Ian Rankin in Edinburgh, include DH Lawrence and EM Forster.
Mr Barry, whose novel has already won the Costa Book of the Year award and is a contender for this year’s Man Booker prize, said he was overjoyed to be given the prize.
He said: “The James Tait Black not only unfurls a great tail of eternally shining writers, but the body of the comet in the present time contains mighty names. A signal moment of unalloyed joy.”
One of Britain’s foremost literary biographers, Michael Holroyd’s award win came after his wife, Margaret Drabble, scooped the accolade in 1967 for her novel, Jerusalem the Golden.
He said: “In 1921 my biographical subject – some would say victim – Lytton Strachey won this prize for his Life of Queen Victoria; and in 1967 my wife, Margaret Drabble, won the fiction award.
“I am delighted to be following them – though I shall never quite catch them up.”
The James Tait Black Memorial Prizes have been awarded by the University of Edinburgh since 1919 and are the only major British literary awards judged by scholars and students.
Professor Colin Nicholson, a judge for the awards, said all the shortlisted books were worthy of the prize.
Irish writer Sebastian Barry won for the Secret Scripture
He added: “It was a very strong field of submissions this year, so that even coming to the short-list was more than usually difficult.
“Each of our final contenders is a prize-worthy example of the writer’s craft.”
The five novels competing for the fiction prize were: Sputnik Caledonia by Andrew Crumey; A Mercy by Toni Morrison; The Secret Scripture by Sebastian Barry; A Case of Exploding Mangoes by Mohammed Hanif; and Pilcrow by Adam Mars-Jones.
The shortlisted works for the biography section were: Arthur Miller 1915-1962 by Christopher Bigsby; A Strange Eventful History: The Dramatic Lives of Ellen Terry, Henry Irving and their Remarkable Families by Michael Holroyd; Gabriel Garcìa Márquez: A Life by Gerald Martin; Edward Carpenter: A Life of Liberty and Love by Sheila Rowbotham; and Chagall: Love and Exile by Jackie Wullschlager.