McGregor was born on 31 March 1971 in Perth, Scotland, and was raised in nearby Crieff. His mother, Carol Diane (née Lawson), is a retired teacher at Crieff High School and latterly deputy head teacher at Kingspark School in Dundee. His father, James Charles Stewart "Jim" McGregor, is a retired physical education teacher and careers master at the independent Morrison's Academy in Crieff. He has an older brother, Colin (born 1969), a former Tornado GR4 pilot in the Royal Air Force. His uncle is actor Denis Lawson and his aunt by marriage was actress Sheila Gish, which makes him a step-cousin of Gish's actress daughters, Kay Curram and Lou Gish.
In September 2020, after travelling through Chile for his motorcycle documentary Long Way Up, he revealed that one of his great-grandfathers, John “Juan” Charles McIndoe, was born in Chile to Scottish parents while his father worked with the American engineers in the construction of the railways at the end of the 19th century. Later, John McIndoe went to Glasgow and worked as a wine importer and diplomat. For his education McGregor attended Morrison's Academy. After leaving school at the age of 16, he worked as a stagehand at Perth Theatre and studied a foundation course in drama at Kirkcaldy College of Technology, before moving to London to study drama at the Guildhall School of Music and Drama when he was 18 years old.