He was included in the Test squad against Sri Lanka in 2006 following injuries to Steve Harmison, James Anderson and Simon Jones, and earned his first cap on 11 May 2006 in the first Test at Lord's, becoming England's 633rd Test player. England reached an imposing first-innings score of 551, and Mahmood took three wickets in his first four overs in Test cricket at the end of the second day, as the Sri Lankan team disintegrated to 91 for 6 at the close. He was unable to add to his tally before Sri Lanka were forced to follow on early on the third day, but added two further wickets in Sri Lanka's more composed second innings on the fourth day.