McAvoy was born on 21 April 1979 in Glasgow, Scotland, to Elizabeth (née Johnstone), a nurse, and James McAvoy senior, a bus driver. He was raised on a housing estate in Drumchapel, Glasgow by his maternal grandparents (James, a butcher, and Mary), after his parents divorced when James was 7. He went to St Thomas Aquinas Secondary in Jordanhill, Glasgow, where he did well enough and started 'a little school band with a couple of mates'.
McAvoy toyed with the idea of the Catholic priesthood as a child but, when he was 16, a visit to the school by actor David Hayman sparked an interest in acting. Hayman offered him a part in his film The Near Room (1995) but despite enjoying the experience McAvoy didn't seriously consider acting as a career, although he did continue to act as a member of PACE Youth Theatre. He applied instead to the Royal Navy and had already been accepted when he was also offered a place at the Royal Scottish Academy of Music and Drama (RSAMD).
He took the place at the RSAMD (now the Royal Conservatoire of Scotland) and, when he graduated in 2000, he moved to London. He had already made a couple of TV appearances by this time and continued to get a steady stream of TV and movie work until he came to attention of the British public in 2004 playing car thief Steve McBride in the successful UK TV series Shameless (2004) and then to the rest of the world in 2005 as Mr Tumnus, the faun, in Disney's adaptation of C. S. Lewis's The Chronicles of Narnia: The Lion, the Witch and the Wardrobe (2005). In The Last King of Scotland (2006) McAvoy portrayed a Scottish doctor who becomes the personal physician to dictator Idi Amin, played by Forest Whitaker. McAvoy's career breakthrough came in Atonement (2007), Joe Wright's 2007 adaption of Ian McEwan's novel.
Since then, McAvoy has taken on theatre roles, starring in Shakespeare's 'Macbeth' (directed by Jamie Lloyd), which launched the first Trafalgar Transformed season in London's West End and earned him an Olivier award nomination for Best Actor. In January 2015, McAvoy returned to the Trafalgar Studios stage to play Jack Gurney, a delusional English earl, in the first revival of Peter Barnes's satire 'The Ruling Class', a role for which he was subsequently awarded the London Evening Standard Theatre Award's Best Actor.
On screen, McAvoy has appeared as corrupt cop Bruce Robertson in Filth (2013), a part for which he received a Scottish BAFTA for Best Actor, a British Independent Film Award for Best Actor, a London Critics Circle Film Award for British Actor of the Year and an Empire Award for Best Actor. Most recently, he reprised his role as Professor Charles Xavier in X-Men: Days of Future Past (2014), and starred in the next film in the franchise, X-Men: Apocalypse (2016), and M. Night Shyamalan's thriller Split (2016).