Dalyell was born Thomas Dalyell Loch in Edinburgh, and raised in his mother Nora Dalyell's family home, the Binns, near Linlithgow, West Lothian; his father (Percy) Gordon Loch, C.I.E. (1887–1953), was a colonial civil servant and a scion of the Loch family. Highland Clearances facilitator James Loch (1780–1855) was an ancestral uncle. Loch (and his son) took his wife's surname in 1938; through his mother Dalyell inherited the baronetcy of Dalyell, and was entitled to be known as Sir Thomas Dalyell of the Binns, 11th Baronet. However, he never used the title.
Dalyell was educated at the Edinburgh Academy and Eton College. He did his National Service with the Royal Scots Greys from 1950 to 1952, as an ordinary trooper, after failing his officer training. He then went to King's College, Cambridge, to study mathematics, but switched to history. He became Chairman of the Cambridge University Conservative Association and Vice-President of the Cambridge Union Society. Cambridge economist Joan Robinson encouraged him to stay for a year after completing his history degree to take an additional degree in economics, which he did and later described as "the hardest work I ever did, much harder than being a PPS". He then trained as a teacher at Moray House College in Edinburgh and taught at Bo'ness Academy for three years and was Director of Studies on the ship school Dunera 1961–1962.
In 1969 Dalyell became a columnist for New Scientist magazine, contributing Westminster scene (later Westminster diary) until his retirement in 2005. This provided "a conduit for researchers to speak to Parliament and vice versa", covering many subjects of public concern including industrial diseases, data protection, chemical weapons and the environment.
Having been educated by left-wing economists at Cambridge, Dalyell said that he became a socialist because of the level of unemployment in Scotland. He joined the Labour Party in 1956, after the Suez Crisis. After being unsuccessful as parliamentary candidate for Roxburgh, Selkirk and Peebles in 1959, he became a Member of Parliament in June 1962, when he defeated William Wolfe of the Scottish National Party in a hard fought by-election for West Lothian. From 1983 onwards, he represented Linlithgow (when the New Town of Livingston formed its own constituency) and easily retained the seat. He became Father of the House after the 2001 General Election, when Sir Edward Heath retired. He was a nominated Member of the European Parliament from 1975 to 1979, and a member of the Labour National Executive from 1986 to 1987 representing the Campaign group.
Dalyell's independent stance in Parliament ensured his isolation from significant committees and jobs. His early career was promising and he became Parliamentary Private Secretary (PPS) to Richard Crossman. He annoyed a number of ministers and was heavily censured by the Privileges Committee for a leak about the biological weapons research establishment, Porton Down, to the newspapers (though he said that he thought the draft minutes of the Select Committee on Science and Technology were in the public domain). When Labour lost power in 1970, his chances of senior office were effectively over. He was opposed to Scottish devolution and was the first to pose the "West Lothian question", although it was given its name by Enoch Powell. He continued to argue his own causes: in 1978–79 he voted against his own government over 100 times, despite a three-line whip.
In the 1990s, Dalyell asked the Lord Advocate, Lord Rodger of Earlsferry, to grant diplomatic immunity to Lester Coleman, a co-author of Trail of the Octopus, so that he could give evidence in the Lockerbie bombing trial in Scotland; the Federal Government of the United States had indictments against Coleman, accusing him of passport fraud and perjury. Allan Stewart, a former Office Minister of Scotland and a Conservative Party MP for Eastwood, also said that Coleman should be granted immunity so he could testify in Scotland. The Lord Advocate rejected Dalyell's plea, saying that the Home Office and the English courts had jurisdiction over the demand of the US government's extradition demand regarding Coleman, and that the Crown Office and the Scottish Office had no authority over the case. Dalyell later said, "I had contact with Les Coleman 10 years ago. In my opinion, though he has a chequered history, I take him seriously."
Dalyell was vocal in his disapproval of actions he deemed imperialistic. Beginning with his opposition to action in Borneo in 1965, he contested almost every British military action, arguing against action in Aden, the depopulation of Diego Garcia, the Falklands War (especially the sinking of the General Belgrano), the Gulf War and action in Kosovo and Iraq. "I will resist a war with every sinew in my body", he said. When invited by a television journalist to rank Tony Blair among the eight prime ministers he had observed as a parliamentarian, he cited policy over Kosovo and Iraq as reasons for placing his party leader at the bottom of the list. He was also a strong presence in Parliament concerning Libya and led no fewer than 17 adjournment debates on the Lockerbie bombing, in which he repeatedly demanded answers by the Government to the reports of Hans Köchler, United Nations observer at the Lockerbie trial.
In February 2003 he became the first Father of the house to be ordered to leave the chamber, after asking questions about the government's "dossier" on weapons in Iraq. Following his outspoken opposition to the 2003 invasion of Iraq and criticism of the Government, Downing Street suggested that he might face withdrawal of the Labour whip. In May, the American magazine Vanity Fair reported Dalyell indirectly as saying said that Prime Minister Tony Blair was unduly influenced by a "cabal of Jewish advisers". He specifically named Lord Levy, who was Blair's official representative in the Middle East, and Labour politicians Peter Mandelson (whose father was Jewish) and Jack Straw (whose great-grandfather was Jewish). Mandelson said that "apart from the fact that I am not actually Jewish, I wear my father's parentage with pride". Dalyell denied accusations that the remarks were anti-Semitic. In March 2003, regarding the 2003 invasion of Iraq, Dalyell accused Blair of being a war criminal. He stated that "since Mr Blair is going ahead with his support for a US attack without unambiguous UN authorisation, he should be branded as a war criminal and sent to The Hague".
On 7 March 2003, Dalyell was elected Rector of the University of Edinburgh. After a three-year term, he was succeeded in 2006 by Mark Ballard. It was announced on 13 January 2004 that Dalyell would stand down from Parliament at the next election, and he left the House of Commons in April 2005 after 43 years as a member of the Commons. He had been Scotland's longest-serving MP since the resignation of Bruce Millan in 1988. He was succeeded as Father of the House by Alan Williams. In 2009, The Daily Telegraph reported that Dalyell had submitted an expenses claim for £18,000 for three bookcases just two months before his retirement from the House of Commons. Dalyell claimed that this was a legitimate expense to which he was entitled; the House of Commons' Fees Office released £7,800.
Dalyell was bestowed with an Honorary Doctorate from Heriot-Watt University in 2011.
He married Kathleen Wheatley, a teacher, on 26 December 1963; she was the elder daughter of the late Baron Wheatley, one-time Lord Advocate and Labour MP for East Edinburgh. They have a son Gordon Wheatley Dalyell, and a daughter Moira, both of whom are lawyers. He was a 6th cousin of Harry S. Truman through the daughter of the 1st Baronet Dalyell of the Binns. In his retirement, and for some years previously, he contributed obituaries to The Independent. In 2011 he published his autobiography, The Importance of Being Awkward. The dedication is "To the men and women of West Lothian – Labour, SNP, Conservative, Liberal, Communist – who, whatever their political opinions, were kind to me in all sorts of ways over 43 years as their representative in the House of Commons."
Dalyell died at home, aged 84 after a short illness.