The former Nottingham Forest midfielder has been at Greenwich Avenue since 2017 when he joined from then-National League North side Gainsborough Trinity.
Thornhill spent five years at the City Ground from 2006, scoring five times, before joining Brighton & Hove Albion and Cheltenham Town on loan deals.
A move to Scotland saw him link-up with ex-Forest boss Colin Calderwood at Hibernian, but his time at Easter Road was blighted by injury and the midfielder returned back to England a year later after only 15 appearances.
The 32-year-old has also featured for Buxton and Shaw Lane.
Manager Steve Chettle said: “It is vitally important that we set out to continue where we have been for the last two [incomplete] seasons and Matt has been a massive part of that, and he has a been a key figure in the success of this club in the last five years.
“His attitude to all parts of the games and training is an example to all and his contribution in assists and goals over the years has been fantastic.
“For the captain to commit to the next two seasons is brilliant for us and it really shows his desire to move forwards with Basford United as it does for everybody here - he is a fans favourite and for the captain to re-sign really shows our intentions.
“It’s great to have Matty sorted and over the line and I’m sure he, like everyone else, can’t wait to get re-started again.”
Chairman Chris Munroe added: “Matt has shown the club, Steve and myself a great deal of loyalty over the years and my dream is that he finishes his playing career with us at Basford, which is now a real possibility.
“There is nothing better for our fans than to see Matt scoring goals or contributing numerous assists and we hope that continues in good supply moving forward as we enter an exciting phase for the football club.
“We thank each party for getting the deal done, made easier by the desire of all concerned to make this happen.”
Kieran Preston, Stef Galinski, Ryan Wilson, Callum Chettle, Marcus Marshall and Kane Richards have all put pen-to-paper recently as United’s preparations for next season continue following the curtailment of the current campaign.