Does a conference talk in an invited session count as an invited talk?
Yes, you can list this as an invited talk.  Even though the first invitation was not to you, the second invitation most certainly was.

Here is another way of thinking about it that may make it clear: imagine that rather than inviting your professor, the organizer has simply asked your professor: "Who do you think would be good to invite to my session?" and your professor suggests you.  This would clearly be an invitation (albeit one where you benefit from your professional network, which often happens).  The only difference between this situation and yours is that the suggestion was preceded by a failed invitation of your professor.