With one game to be played, 2004 champion Greece has 21 points, two ahead of Croatia, and needs a draw against Georgia in Tbilisi on Tuesday to make sure of qualification. Croatia hosts Latvia on Tuesday.
Gekas, who had quit the national team a year ago, citing animosity with teammates, celebrated his goal by running to hug Giorgos Karagounis and Costas Katsouranis, the two veterans he had reportedly clashed with.
Gekas had returned to the team last week after apologizing publicly.
''I knew we would create chances ... We defended the Croats' counterattacks rather easily,'' said Greece's Portuguese coach Fernando Santos, who remains undefeated at Greece's helm.
The game was less than three minutes old when it was temporarily stopped because of crowd trouble. More than a 100 masked men, many of whom also wearing motorcycle helmets, suddenly attacked the Croat supporters with flares and one petrol bomb. The Croats threw seats at their attackers and briefly scuffled with riot police, who used pepper spray. The match was suspended for six minutes.
The stoppage seemed to throw Greece off its game completely, but Croatia could not take advantage of the hosts' disarray, even though it controlled play for the remainder of the first half. Croatia could manage only two long-range efforts, by Niko Kranjcar in the 21st minute and Mario Mandzukic in the 27th, none of which bothered goalkeeper Alexandros Tzorvas. Greece managed only a weak header by defender Avraam Papadopoulos in the 43rd.
The hosts also lost one of their mainstays, Vassilis Torosidis, who hurt his ribs in a midair collision with an opponent.
Greece began the second half with greater purpose and had its first real scoring chance in the 48th. Yiannis Zaradoukas charged down the left flank and sent a perfect cross for Gekas, whose header was blocked by goalkeeper Stipe Pletikosa.
Greece opened the scoring in the 71st when Karagounis took a corner from the right and Katsouranis had a shot cleared off the line by Ivan Strinic.
Karagounis crossed the ball back in for Dejan Lovren to head the ball on to Samaras, who blasted a shot into the net past the diving Pletikosa.
Greece continued to press forward and scored its second goal eight minutes later when Gekas headed in Karagounis' corner kick.
A minute before Gekas' goal, Nikola Kalinic, who had replaced Nikica Jelavic in the 62nd, was injured and, with the Croats having already used their three substitutions, left his team a man short.
''Greece won fairly. I congratulate them ... There is still one game left, but qualification is not in our hands now,'' said Croat coach Slaven Bilic. ''It is difficult to create chances with Greece, because they defend very well.''
Greece: Alexandros Tzorvas, Yiannis Zaradoukas, Avraam Papadopoulos, Vassilis Torosidis (Loukas Vyntra, 43), Sokratis Papastathopoulos, Alexandros Tziolis (Giorgos Fotakis, 62), Giorgos Karagounis (Grigoris Makos, 88), Costas Katsouranis, Georgios Samaras, Dimitris Salpingidis, Fanis Gekas.
Croatia: Stipe Pletikosa, Ivan Strinic, Josip Simunic, Dejan Lovren, Vedran Corluka (Domagoj Vida, 75), Ognjen Vukojevic, Nikica Jelavic (Nikola Kalinic, 62), Luka Modric, Mario Mandzukic, Niko Kranjcar, Eduardo (Ivan Perisic, 52).