Verse 39:[1] And Gaal went out before the men of Shechem, and fought with Abimelech.
[Therefore, Gaal went out] He fights, but perhaps less prepared: for Abimelech had arrived unexpectedly (Martyr).
Verse 40:[2] And Abimelech chased him, and he fled before him, and many were overthrown and wounded, even unto the entering of the gate.
He fled before him; being surprised by the unexpected coming of Abimelech, and possibly not fully prepared for the encounter. Many were overthrown and wounded, being pursued and overtaken by Abimelech.
[1] Hebrew: וַיֵּ֣צֵא גַ֔עַל לִפְנֵ֖י בַּעֲלֵ֣י שְׁכֶ֑ם וַיִּלָּ֖חֶם בַּאֲבִימֶֽלֶךְ׃
[2] Hebrew: וַיִּרְדְּפֵ֣הוּ אֲבִימֶ֔לֶךְ וַיָּ֖נָס מִפָּנָ֑יו וַֽיִּפְּל֛וּ חֲלָלִ֥ים רַבִּ֖ים עַד־פֶּ֥תַח הַשָּֽׁעַר׃
Matthew Henry: 'Abimelech routed Gaal's forces that sallied out of the town, Judges 9:39, 40. Gaal, disheartened no doubt by Zebul's hectoring him, and perceiving his interest weaker than he thought it was, though he marched out against Abimelech with what little force he had, was soon put to the worst, and obliged to retire into the city with great precipitation. In this action the Shechemites' loss was considerable: Many were overthrown and wounded, the common effect of popular tumults, in which the inconsiderate multitude are often drawn into fatal snare by those that promise them glorious success.'