He suffered a shock defeat by world number 117 Denis Istomin at January's Australian Open, where he was defending champion, and then lost his French Open crown when he was beaten by Dominic Thiem in the quarter-finals in June.
Djokovic said he would spend the time building up his fitness and strength, as well as working on areas of his game he felt needed to be improved.
"I want to play professional tennis for many years to come," he added in a message on his Facebook page.
It means Djokovic will miss the US Open, which starts on 28 August, and where he was champion in 2011 and 2015.
His absence from Flushing Meadows ends a run of 51 consecutive appearances at Grand Slams.
"All the doctors I've consulted, and all the specialists I have visited, in Serbia and all over the world, have agreed that this injury requires rest," Djokovic said.