Djokovic, 33, showed his frustration after losing serve to trail 6-5 against Spain's Pablo Carreno Busta.
The Serbian world number one took a ball out of his pocket and hit it behind him, striking the female line judge in her throat.
After a lengthy discussion, he was defaulted by tournament officials.
Players who hit another person on the court can be automatically disqualified from the competition by way of a loss. Djokovic realized immediately he hit her and approached the person.
Pablo Carreno Busta will advance to the quarterfinals and there will be a new Grand Slam men’s singles champion for the first time in six years.
Djokovic appeared to plead his case to tournament referee Soeren Friemel and Grand Slam supervisor Andreas Egli during a long conversation at the net.
Eventually, however, he accepted his fate and shook hands with Carreno Busta, who looked shocked by what had happened as he waited for a decision in his chair.
Djokovic left Flushing Meadows without doing his news conference and later posted an apology on his Instagram page.