The small amount of research I just did suggests that the networks pay the local stations the affiliate fees: http://www.businessinsider.com/heres-how-the-tv-business-act...
I had assumed the locals were paying to get content from the networks, but that doesn't seem to be the case (also indicated in another comment.)