The ruling came after two days of testimony over a lawsuit brought against the city by AFSCME District Council 47.
That means the 20% of the workforce that has been on a hybrid schedule will be in the office five days per week starting Monday.
Judge Sierra Thomas Street said Friday she didn't think the union was able to prove reputable harm.
Mayor Cherelle Parker announced the July 15 deadline in May and made it clear earlier this week she was not backing down.
The union posted a response on social media shortly after the ruling Friday, saying the fight is not over.
While union leaders vowed to keep pursuing what they call a "fair resolution," leadership did call on members to report to their worksite as scheduled on Monday.
Union leadership has argued their members have been doing hybrid work for four years without issue. Doing away with it, they argued, will affect child care, elder care, medical issues and work-life balance.
In court, city employees took the stand as they referred back to emails and meetings between both sides discussing the language about virtual work policies and flex scheduling.
The union is not happy with this decision and says they are prepared for people to start looking for new work.
"Obviously we're very disappointed with the judge's decision. We're disappointed that she does not see the harm that this is going to cause our members," said AFSCME District Council 47 President April Gigetts.
"We know that this is going to have a devastating impact. Some people may leave right away. Some people may wait until they get employment," she added.
Gigetts said she hopes the Parker administration will accept a request for expedited arbitration.
Mayor Parker news conference reaffirming return to office date for Philadelphia city workers
City officials said they are counting on their workforce to step up to the plate. They're thankful for the judge's ruling, saying the mayor promised the city a government they could "see, touch and feel."
"Today's decision is a giant step toward realizing those promises," said Chief Administrative Officer Camille Duchaussee.
Mayor Parker said Wednesday that having staffers back in the office full-time promotes "personal and productive interactions for facilitating communication, promoting social connections, along with collaboration, innovation, inclusion and belonging."
The union said it plans to appeal.
In a statement, Mayor Parker said, "I want every member of our workforce to know: I'm a pro-Union, pro-worker mayor, and I thank you for all your service every day to make Philadelphia better."