The Posh are currently four points ahead of the rock-bottom Tykes and on Saturday lost 1-0 to Derby County, another side fearing the drop.
That proved to be the final straw for Ferguson, who the club say contacted owner Darragh MacAnthony on Sunday to tender his resignation.
Sheffield Wednesday boss and chairman unhappy after attackers leave for Premier League
What Darren Moore had to say after Sheffield Wednesday's win over Charlton Athletic
Sheffield Wednesday ‘obviously huge’ but Charlton Athletic boss makes Owls statement
The moment that changed the game and a star man rises – How Sheffield Wednesday battled their way past Charlton Athletic
Sheffield United: Boss's vow over £40m strike pair as Oli McBurnie enters make or break season
Peterborough accepted and now begin the search for a new boss to steer the club away from trouble, having described Ferguson as ‘one of the greatest managers of this football club’.
Ferguson was in his third spell in charge of Peterborough, with spells at Preston and Doncaster Rovers in between, and last season took them to the Championship by way of automatic promotion from League One.
MacAnthony said in a statement posted on the club’s official website: “Myself and my two partners regard Darren as one of the greatest managers of this football club, most certainly in the modern era. The success we have enjoyed with him at the helm has been unrivalled and he will always be described as a legend by myself and my partners.
“I want to personally thank him for all his hard work on behalf of the club, particularly in his third spell when he dealt with the unquestionable frustration at the season being cut-short due to Covid-19 and then responding by securing promotion the following season against all the odds.
“The financial constraints he had to work under due to the impact of no supporters inside the stadium was something that nobody could have foreseen, and he dealt with that in such an admirable and methodical way. He created a working environment that the players enjoyed despite the restrictions and he deserves enormous credit for that and the success we enjoyed.”
Peterborough are set to take on top-of-the-table Fulham on Wednesday night, while Barnsley have a Yorkshire derby against Hull City on Tuesday. Derby County host Millwall.
Ferguson's departure is the second managerial exit at the bottom of the Championship this weekend, after fourth-bottom Reading sacked Veljko Paunović and replaced him with Paul Ince on a temporary basis.