He has played in the Sweden national team since 20 November 2002, when he made his debut against the Czech Republic in which he scored two goals in a 3–3 draw.
During the 2010 FIFA World Cup qualification Sweden changed to 3–5–2 formation, placing Nilsson again on the midfield.
On 6 June 2009, Sweden played a 2010 FIFA World Cup qualifying match against Denmark at the Råsunda Stadium in Solna.
Nilsson made a terrible mistake that caused Sweden to lose 0–1 and eventually miss the World Cup.
Somehow, he managed to get the ball on his left leg, causing it to roll across the goal-line and to the Danish midfielder Thomas Kahlenberg who scored easily.