He told reporters on Monday his decision to leave politics was centred on personal reasons rather than Ms Berejiklian's abrupt exit as premier.
He said he had been considering his departure for some time, with the timing brought forward by the reshaping of the state government's leadership team.
"There is never a right or wrong time to leave politics," he said.
"[But] I genuinely think it is the right and proper thing to be honest with people and not put my hand up."
Mr Barilaro said he believed it was time for a "refresh" as NSW prepares to emerge from the lockdown caused by the COVID-19 pandemic.
"Yes, it is a tough time, but I think it's the right thing to do," he said.
Mr Barilaro will now work with the speaker and electoral commission to organise a by-election for his seat of Monaro in southern NSW.
He has also ruled out taking a tilt at federal politics in the next election, following his exit from state parliament.
"I have no intention and no will that I will be running for Eden-Monaro or for federal politics - I am leaving politics," he said.
He previously announced last year he would run in the seat of Eden-Monaro before pulling out some 24 hours later.
Mr Barilaro was first elected to the NSW parliament in 2011 and took over as deputy premier in 2016.
John Barilaro resigns as Deputy NSW Premier
In a statement, Mr Barilaro reflected on his time in politics, which included responses to drought, the worst bushfires in living memory, severe storm and flood disasters, and a one-in-100 year global pandemic.
But the son of Italian migrants also said his experience had been marred by racism, describing being subjected to disgusting and vile commentary in an ongoing defamation case against YouTube personality Jordan Shanks.
"A young boy of migrant parents, I grew up, I understood what racism was," he said.
"I didn't think in 2021 that would continue. That in itself, can I say, was very difficult this year."
Mr Barilaro's resignation comes ahead of a NSW Liberal party room meeting on Tuesday to decide on Ms Berejiklian's replacement.
NSW Treasurer Dominic Perrottet has emerged as the frontrunner to succeed Ms Berejiklian and is appealing to his Liberal colleagues to back him after striking a deal to make Stuart Ayres his deputy.
The resignation of Ms Berejiklian and Liberal MP Andrew Constance's decision to quit state politics to run at the next federal election will also set up separate by-election contests.
The Coalition currently holds a slim majority in the NSW Legislative Assembly making any potential loss of a seat significant.