Philadelphia erased a 1-0 deficit in the 59th minute on a penalty kick goal from Freddy Adu after defender Kevin Alston was ruled to have brought down McInerney in the box.
Then, with time ticking down, Sheanon Williams sent a cross through the 6-yard box to the left post, where McInerney sneaked behind Alston and headed it across the goal line in the 90th minute.
The Union (7-10-2) improved to 5-2-0 in their last seven games, using the win to pull even with the Revolution (6-10-5) for eighth place in the Eastern Conference.
Saer Sene scored his ninth goal of the season in the first half for New England.
Dog comes home gnawing on human bone
Julius Randle breaks leg during NBA debut