Ainsley, who took the club from Step 5 into the National League North, was one of the longest serving managers in English football.
The decision to make the change was agreed mutually, the Moors announced.
Popular Ainsley, 50, managed the club for nearly 800 games in a decade-and-a-half, winning 11 trophies - including the FA Vase at Wembley.
Assistant manager Tommy Miller will take charge against York City on Saturday.
Chief Executive Brad Groves said: “Jason and I have been in agreement for a long time that there would be a clear moment where this change was needed; it has always been in the long term plan for the club.
“With the scale of our ambition and the multi-million-pound investment I have made in the club, there is now increased pressure on performance across the board. With the additional pressure the Covid-19 pandemic has brought, that moment has arrived quicker than we thought.”
He added: “As someone who said he was not sure he had what it takes to be a football manager when I joined the club, Jason has achieved some incredible things at the helm of the team.
“There are obvious ones like the FA Vase, the amazing trip to Guernsey, the FA Cup First Round Proper and all of the silverware. But there have been so many late comebacks, memorable performances, and crucial wins too. That is testament to the character he instilled in his players year after year.
“There is no doubt he will go down in history as one of the most influential and loved people ever at this club. He is already a legend within Spennymoor and is a cherished friend of my family, which will always be the case.
“This is not the end of Jason’s story with the club. There will be plenty of opportunities for supporters to see him and his family in person at the match in the future to show their gratitude for what he has done for Spennymoor.
“We are already in discussions for him to use his expertise and keep his passion for football and Spennymoor alive in other ways with us. But, for now, I am pleased he is taking some time for a well-earned rest.”