The visitor trailed to Renato Steffen's strike on the half-hour mark, but hit back with three goals in nine second-half minutes from Steven Zuber (49), Nassim Ben Khalifa (56) and Nzuzi Toko (58).
Thun got on the scoresheet again after 64 minutes through Marco Schneuwly but failed to make its pressure count in the final 25 minutes.
Grasshoppers remains two points clear of St Gallen, which was a 2-1 winner at home to Lausanne.
Ezequiel Scarione's 20th-minute opener for St Gallen was cancelled out by Chris Malonga Ntsayi two minutes into the second half.
However, Philippe Montandon scored the decisive goal after 54 minutes.