If it's Nagato in full health, then Nagato would win.
Nagato
-Complete Mastery of Fire Techniques
-Complete Mastery of Water Techniques
-Complete Mastery of Wind Techniques
-Complete Mastery of Lightning Techniques
-Complete Mastery of Earth Techniques
-Shinra Tensei
-Chibaku Tensei
-Bansho Tenin
-Can suck the souls out of bodies on contact
-Can absorb all forms of ninjutsu and chakra-based attacks
-Can summon any animal he choses
-Can summon forth mechanic extensions and missles
-Summoning Technique: Gedo Mazo
Nagato could, in theory, counter any of Madara's ninjutsu techniques because he has full mastery of all elements.
-If Madara attacks with Fire, Nagato counters with Water.
-If Madara attacks with Water, Nagato counters with Earth
-If Madara attacks with Earth, Nagato counters with Lightning
-If Madara attacks with Lightning, Nagato counters with Wind
-If Madara attacks with Wind, Nagato counters with Fire
If that's not enough he could just absorb them instead. This nullifies Madara's ninjutsu
Nagato can suck the soul out of anyone he grabs or touches. He can also spring forth powerful mechanic arms to block and attack. This basically nullifies Madara's taijutsu
Nagato can hide in his camouflaged chameleon. Madara can't use genjutsu if he can't see Nagato. This seals away Madara's use of genjutsu.
Madara has Susanno which would probably be the biggest problem for Nagato. But Nagato can spam his summons and summon his multiplying dogs, his birds, his chameleon, and any other summonings he has. This could more than keep Madara's Susanno occupied.
I don't want to sound like I'm underestimating Madara, because I know he's powerful. But at the same time you can't ignore how powerful the Rinnegan is. Nagato has so many tricks up his sleeve that he can counter anything Madara throws at him.