The Tykes went into the match with only 12 senior players and Academy youngsters, with the likes of David Perkins, Luke Steele, Matty Done, Jim McNulty and Jim O'Brien all missing.
They did not make life easy for themselves following Mellis' close-range header as Bobby Hassell was sent off shortly afterwards, but held on despite late Robins pressure.
Bristol City made one change to their line-up, with striker Sam Baldock, a scoring substitute in the impressive 4-2 win against Cardiff, handed a first start.
The Robins, who had netted eight goals in their last two matches, started brightly, with Baldock clearing the crossbar after connecting with Mark Wilson's corner.
Jon Stead was next to try his luck from 25 yards but his effort was comfortably gathered by goalkeeper Ben Alnwick.
The home side responded through Mellis, who fired straight at Tom Heaton from just inside the area after Craig Davies had fluffed a chance.
Chris Dagnall's drive from distance failed to trouble Heaton, while Mellis was wayward with another attempt as Barnsley looked to capitalise on their pressure.
Davies tested the keeper twice in quick succession and the lively Tomasz Cywka was not too far away with an 18-yard strike.
It was all Barnsley as half-time approached with Mellis and Stephen Dawson both trying long-range efforts but the game remained goalless.
Bristol City brought on Marvin Elliott for Albert Adomah at the start of the second half but he had little time to settle before the Tykes took the lead.
Great play from Martin Cranie down the right saw the full-back cross from the byline for Mellis to bullet a header past Heaton.
Barnsley fans were still celebrating when their afternoon took a turn for the worse. Defender Hassell was shown a straight red card for an off-the-ball incident involving Stead.
The dismissal gave the Robins fresh impetus and after Baldock brought a comfortable stop from Alnwick, Cole Skuse saw an effort blocked by Scott Wiseman.
Goalscorer Mellis, who had pulled the strings in midfield, was part of a double substitution on the hour as Davies also went off to be replaced by John Stones and Marlon Harewood.
As the Tykes looked to hold on to their lead, Baldock, who had been quiet in the second half, left the action for Ryan Taylor as the visitors went in search of an equaliser.
Steven Davies was then brought on by Derek McInnes and he almost scored with his first touch, heading inches wide from six yards after good work from Greg Cunningham.
The same player came agonisingly close to snatching a point late on when his 25-yard free-kick came back off the crossbar.