Hammill was impressive throughout and was the spearhead of every Barnsley attack, with only an excellent performance by Jamie Ashdown in the Portsmouth goal preventing him from adding to his excellent 13th minute effort.
Barnsley manager Mark Robins named an unchanged side as they looked to build on two successive npower Championship victories, while Pompey boss Steve Cotterill was without the suspended Carl Dickinson after his sending off last week.
The opening exchanges were dominated by Barnsley and the first attempt of the game came from Nathan Doyle, who tested Ashdown with a 25-yard strike and added more pressure soon after with Hammill swinging in some testing corners which troubled the visitors defence.
The dangerous Hammill then made Pompey pay as he broke the deadlock with a brilliantly taken shot that gave Ashdown no chance after good work from Gary O'Connor to put the home side into the ascendancy.
Portsmouth started to settle and slowly began to assert themselves on the game with John Utaka testing home goalkeeper Luke Steele with a long-range effort.
Hammill and O'Connor linked up well again causing the Pompey defence plenty of problems and the former Liverpool winger went close but this time was off target as his shot rolled wide of the post.
The Barnsley defence were very organised and easily dealt with Liam Lawrence's testing crosses while at the other end the Tykes looked dangerous on the attack and some neat play from Goran Lovre found O'Connor but he blazed his volley over the bar.
Jim O'Brien almost doubled the home side's advantage when he beat Ashdown but his shot was fractionally wide of the post and Portsmouth were very lucky to have 11 men on the field as Aaron Mokoena handled the ball to prevent another Tykes attack. From the resulting free-kick, O'Brien had two chances to shoot but Ashdown was equal to both and parried both efforts away from danger.
Hammill continued to impress after the interval and had another shot which troubled Ashdown, who managed to fumble it away to safety.
Minutes later O'Connor brought the best out of the Pompey goalkeeper, tipping the on-loan Birmingham striker's header onto the bar from a Hammill cross.
Barnsley applied the pressure as they sought to double their advantage with Hugo Colace going close.
Portsmouth pressed to try and find an equaliser late on with Joel Ward wasting two opportunities but it was Hammill's seventh goal of the season which proved to be decisive to give Robins' men their third straight league win.