Atlanta United, arguably the best team in MLS, needed 95 minutes to put away San Jose, arguably the worst team in MLS, 4-3 on Wednesday. And it was a game that changed on one of the weirdest moments in the league this season.

Goals from Hector Villalba, Miguel Almiron and two more from Josef Martinez, who extended the MLS single-season scoring record to 30, helped the team overcome goals by Nick Lima, Danny Hoesen and Valeri Qazaishvili at Avaya Stadium.

The win pushed Atlanta United to 60 points in the race with the New York Red Bulls for the Supporters’ Shield. Atlanta United will host Real Salt Lake on Saturday at Mercedes-Benz Stadium. The Red Bulls have 56 points and will host Toronto on Saturday.

» More: 'Nightmare scenario' sparks Atlanta United win

The Five Stripes set a record for road wins in the post-shootout era with its 10th, and tied the record for points earned on the road (32). The team’s road record improved to 10-3-2.

But those won’t be the talking points on Thursday.

The game changed in the 67th minute on a play that will create more ammunition for those who don’t like Video Assistant Referee and the replay system.

San Jose’s Chris Wondolowski appeared to give his team a 4-1 lead with a goal in the 67th minute. But referee Foti Bazakos reviewed the play. The thought was Wondolowski was offside when the pass to him was made. Bazakos not only took away the goal, but ruled a handball against San Jose’s Magnus Eriksson in the Earthquakes’ penalty box on the other end of the field. Martinez converted the free kick for his 29th goal this season and cut Atlanta United’s deficit to 3-2.

Sparked by the weirdness, Atlanta United tied the game at 3-3 on a goal by Almiron in the 73rd minute, who cleaned up a mess in the box created by Martinez’s efforts.

Martinez headed in the winner in the 95th minute on a cross by Almiron.

Atlanta United manager Gerardo Martino made one personnel change from Saturday’s 3-0 win at Colorado, resting Darlington Nagbe and starting Franco Escobar. Jeff Larentowicz moved from centerback to his customary position as a defensive midfielder, paired with Eric Remedi.

As well as Atlanta United started against Colorado with three goals in the first half, it played just as poorly against San Jose.

Playing on a pitch that appeared to be closer to green ice than grass with all of the slipping and sliding, Atlanta United consistently lost its shape going forward. Players got in each other’s way, which left open holes on the defense.

San Jose jumped out to a 1-0 lead on a goal by Lima in the 14th minute. Lima got behind Chris McCann and headed in a cross from Shea Salinas.

Atlanta United created several scoring chances in the next few minutes, but failed to capitalize on good shots by Julian Gressel and Villalba. Other times, Atlanta United simply made poor decisions that resulted in turnovers.

Villalba looked to have tied the game, but his shot, which beat James Marcinkowski, was cleared off the line by Guram Kashia in the 28th minute. Villalba’s shot was set up Martinez, who was put in on goal by Almiron. Marcinkowski forced Martinez to go wide, so he passed to the open Villalba.

San Jose made Atlanta United pay with a goal by Hoesen in the 44th minute. Hoesen got behind Michael Parkhurst, who slipped for at least the third time, and ran onto a long pass down the middle. Hoesen’s first shot was saved by Brad Guzan. Hoesen ran onto the rebound, took a second and then chipped Guzan.

Atlanta United cut San Jose’s lead to 2-1 on a goal from Villalba in injury time in the first half. Villalba one-timed a pass from Gressel into the top right corner. It was Villalba’s sixth goal and Gressel’s 13th assist.

San Jose added a third in the 59th minute on a goal by Qazaishvili. He spun around McCann on the edge of the penalty box and moved toward goal. McCann couldn’t risk trying a tackle in the penalty box. No one else moved to close down Qazaishvili, who hit a left-footed shot from six yards.