The win marked a memorable homecoming for Liberty head coach Scott Jackson, who is in his first season leading the Flames after eight seasons as an assistant at UNC, as well as former pitcher and Carolina assistant Bryant Gaines.
Both teams squandered run-scoring chances early before Lynn's fifth homer of the year gave the hosts a 1-0 lead in the fourth. Liberty (21-14) responded immediately with D.J. Artis' solo blast in the fifth, but Carolina (29-8) edged back in front on McGee's laser in the bottom half.
Rodney Hutchison Jr. (4-2) entered the game for the Tar Heels in the fifth and kept the Flames at bay until the eighth, when they loaded the bases with two outs on a pair of singles and a walk. McDyre then drove a 1-0 pitch off the wall in left to clear the bases and put Liberty in front for the first time. Jake Barbee's RBI triple made it 5-2.
Carolina left the bases loaded in the eighth, and Jack DeGroat worked around a walk in the ninth for his third save of the year.
Cody Gamble (1-1) worked two scoreless innings of relief to pick up the win. Artis, Barbee and Andrew Kowalo each had three hits for Liberty, which out-hit the Tar Heels 14-4.
Tyler Baum started for UNC and allowed no runs on six hits in four innings.
Carolina returns to conference action Friday with the first of three at Pittsburgh.