Chasing a 21st major that would seal a calendar Grand Slam, Djokovic had difficulty getting into gear against the 99th ranked Brooksby, who for a while looked capable of derailing the Serb.
For the second consecutive match the world No 1 came out flat and dropped the opening set, something he will not want to do in his quarter-final when he faces Italian Matteo Berrettini in a rematch of the Wimbledon final.
The sixth-seeded Italian will mark a big step up in quality for Djokovic, who has not faced anyone ranked inside the top 50, including a qualifier and a wildcard.
The match got off to an extraordinary start as Brooksby took the first set with shocking ease.
Playing for the first time on Arthur Ashe Stadium against one of the all-time greats, Brooksby was unfazed while three-times champion Djokovic sprayed shots helter-skelter, committing 11 unforced errors to just one by the American. That was the wake-up call Djokovic needed and he broke Brooksby at the first opportunity in the second set, letting out a mighty roar.
Djokovic won the second but the 20-year-old American made him work for every bit of it, particularly in a grinding fifth game that lasted close to 20 minutes before Brooksby got the break.
The last American man standing and coming off his first ever five-setter, Brooksby began to fade in the third, going down a double break as Djokovic finally raised his game.
Leading 2-1, Djokovic continued to improve in the fourth and moved clear with a double break and offered zero break point opportunities to his opponent before sealing the win.
“I think the momentum changed midway through the second set when I came through a couple of long games then I started hitting more cleanly,” said Djokovic.
“All in all it was a very physical battle with a lot of exciting rallies, and credit to him for his performance tonight, it was fantastic.”
Fourth seed Alexander Zverev, a potential semi-final opponent for the Serbian, extended his winning streak to 15 matches with a straight-sets victory over Jannik Sinner.
At 20, Sinner has been usurped as the young gun of men’s tennis by Carlos Alcaraz but great things are expected of the Italian and he tested Zverev without being able to take his chances.
Sinner fought back from a break down in the third set and held set point in the tiebreak only to miss a routine forehand, and he paid a heavy price, with Zverev triumphing 6-4, 6-4, 7-6.
The German is riding a wave of confidence, and he said: “I think definitely it’s the reason why maybe the big shots in the important moments they seem more natural, I would say, and you’re not maybe thinking about it twice like you would in some other situations.
“I’m happy where I am, I’m happy with how things are, and I’m happy with how things were the last few months. I’m in the quarter-finals now and from here on, the matches will definitely not get easier.”
In the next round, Zverev will take on one of the tournament’s many surprise packages in South African Lloyd Harris, who reached a first grand slam quarter-final with a 6-7, 6-4, 6-1, 6-3 victory over 22nd seed Reilly Opelka.