Alison covers this very nicely. Two options that I find very useful are saying something when they first interrupt you:
I've only got 5 minutes to talk, and then I need to get back to work.
I'm a bit busy right now. But if you come back in 45 minutes, I should have a few minutes free.
In other words, deflect them right off, in a friendly and ...
There's also the thing about him being my team leader, I feel like I
can't use the "I am really busy" line because it would imply that he
doesn't have anything to do...
I want to keep a cordial professional relationship. How can I
communicate all this without being rude?
Avoiding the "I am really busy" line is not implying anything, nor is it ...