I've seen this cheesy strategy a few times now - loads of marines with all the upgrades and medivacs. This wasn't a rush but still wasn't able to counter playing as zerg.
What's the most effective (zerg) way to counter this strategy?
There are a number of ways you can handle this, and I'll try to break them down for you:
Roaches are what many people consider the Marine's natural Enemy. With high HP (almost 3 times a Marine) and that 1 base armor its not surprising people would believe this. Unlikely in Starcraft 1, Marine's can't upgrade their attack range, so the shorter range of the Roach is punished less. The biggest issue you have to worry about with Roach based play is where you engage your opponent. Ideally you want to engage on open ground, on creep, and with a nice arc. Try to remember that because of the Roaches' short range remember to "move" into melee range, instead of "attack move."
Baneline Style is very popular against MMM in general, and usually used to compliment Roach or Hydra work. If you initially engage with your Roaches (in more Marauder based play you'd use Hydralisks here), and then bring in Banelings from the side or behind (flanking in military terms), you can usually make quick work of any Marine based force. Remember you never attack with Banelings, as they explode on death to do damage. Instead just "move" near the Marine force and let the Marines kill them off. I cannot stress how important baneling speed upgrade is against a Marine force, even on creep.
Infestor Harassment is also a nice compliment to dealing with Marines. While Medivac will heal most of the damage quickly, in the middle of a fight, Infestors can prevent Marines from backing up, while dealing incredible dps (9*#of marines). They are an excellent compliment to a Roach or Zergling based strategy. If you're dealing with Infestors alone, remember that it will usually require 2 Fungal Growths to kill a pack of Marines; where "usually" is influenced by the use of Stim and the presence of Medivacs.
If you're coming from a late game Air strategy it'll make more sense to use Broodlords. Brood Lords are effective because of their high damage, and because Broodlings draw fire from Marines. Because Broodlords are slow, its normally useful to engage from the edge of a cliff, where few Marines can hit you. Unless you have a very large number of Broodlords, this kind of play is unlikely to be effective on its own, and is best complimented with a cheap ground force (something ling based).
Backdooring is usually an effective technique for shutting down late game Terran pushes. Terran style tends to be fairly turtle dependent, so most Terran players will run for their base when ever its in trouble. You can leverage this with Muta Harass, Zergling Drops, or even Nydus Canal. The very fact that you are in his base will often make a Terran call off his assault, giving you more time to prepare.
With the exception of the last strategy, all these strategies are what I like to call "meat and potatoes" strategies. They have some method for killing the Marines and some method for distracting them. This is because Marines are extremely cost effective dps and once they hit critical mass, almost impossible to destroy for a short range based Zerg force. You strategy should look something like this: I need something for him to hit (let's say Ultralisks) and something to kill him (let's say Hydralisks, two units I didn't recommend). You would then engage with your Ultra heavy force, backed by long range Hydra. The Marines will naturally target the Ultra who have high HP and Armor, while the Hydra do the lion's share of the damage. When designing an anti-Marine strategy keep this in mind.
I used to include an explanation of Arcs here, but I've since moved it