SAN JOSE, Calif. (AP) — Conor Casey scored two late goals on headers and the Philadelphia Union rallied to beat San Jose 2-1 on Saturday night, ending the Earthquakes’ winning streak at four games.

Casey entered as a substitute in the 60th minute and tied it in the 74th, finishing Raymon Gaddis’ diagonal cross with a leaping header. The goal snapped San Jose’s 447-minute shutout streak, the longest in MLS this season.

The Union (8-14-6) took the lead in the 86th minute when Casey redirected Tranquillo Barnetta’s free kick with a glancing header.

Chris Wondolowski converted from the spot to open the scoring for the Quakes (11-11-5) in the 64th minute. With a victory, San Jose would have moved ahead of Sporting Kansas City and the Portland Timbers into a fourth-place tie with FC Dallas in the Western Conference.

The Quakes’ Victor Bernardez left the game in the 39th minute with an apparent hamstring injury.

(Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)