Queens Criminal Court judge Suzanne Melendez said Albrecht Stromeyer, 34, would be transferred to an Immigration and Naturalization Service detention center, which will arrange his deportation to Germany within the next few days.
Melendez also issued an order of protection that Stromeyer refrain from contact with Williams and her family and stay away from tennis tournaments or risk being held in criminal contempt and face up to a year in jail.
Stromeyer was arrested Saturday at the National Tennis Center and charged with two counts of stalking after police spotted him watching Williams, the reigning Wimbledon and French Open champion, play a third-round match. Williams has been traveling with a bodyguard since May.
Stromeyer told police he had been following Williams around the world. He was arrested outside Wimbledon in July after scuffling with police, telling officers he loved her and would never hurt her.
In July, a British Magistrates Court ordered Stromeyer to stay out of trouble for 12 months after he smashed a police camera near London's Wimbledon tennis championships venue.
Stromeyer was extradited from Italy in May to face charges of talking to Williams.
Two months earlier, he had walked into an Arizona resort where Williams was playing and asked to see her. When he was turned down, the German began undressing in front of the desk clerk. He was charged with disorderly conduct and indecent exposure.
Melendez said Stromeyer had to seek psychiatric care once he returned to Frankfurt, where he lives with his parents, and that defense lawyer Gerard Savage must report back to the court on Oct. 23 to show evidence that he has complied.
Savage apologized on behalf of his client: "In his mind, it was a love story."
Savage also said Stromeyer had asked him deliver a message to the Williams family.
"He wanted me to say to Serena Williams's family that he's sorry for any inconvenience he caused them and for any fear he may have caused them," Savage said about his long-haired, bearded client.
On Sunday, the tennis player's father, whose older daughter Venus is the twice defending U.S. Open champion, had lashed out angrily about the stalker.
"Would (anything) stop me from killing this guy if he did something to one of my daughters?" Richard Williams told the New York Daily News. "I do not think all the police officers in the world could stop me."