Roger Federer beat Rafael Nadal 6-4 3-6 6-3 in an charity match played at South Africa's Cape Town Stadium on Friday.