STATEN ISLAND, N.Y. -- In a decision that could impact dozens of tenants living in illegal apartments on Staten Island, a judge has ordered a West Brighton landlord to return the security deposit and pay the moving expenses of a tenant forced to leave her unit.

However, Judge Philip S. Straniere said Mary Beth Aquino wasn't entitled to the $1,200 in monthly rent she paid for her Elm Street apartment, because the rental agreement of an illegal dwelling is "unenforceable."

Even so, Ms. Aquino may have other legal recourse. The judge said she could sue the real-estate agent who helped locate the apartment, for failure to determine if it was legal.

"[Ms. Aquino] is entitled to recover her entire security deposit of $1,200 because [Gilbert Ballester, the landlord] is not entitled to keep it when the apartment is illegal and so unsafe that a vacate order had to be issued," wrote Straniere, the supervising judge of West Brighton Civil Court. "[Ms. Aquino] can also recover the monies she had to expend to move to a new apartment in July 2012, which totaled 

$4,400, as she would not have had to expend that money to move on short notice but for the illegality of [Ballester's] apartment."

Straniere ordered Ballester to pay Ms. Aquino $5,600, following a trial in which Ms. Aquino and Ballester each represented themselves.

According to court papers, Ms. Aquino rented a basement apartment from Ballester at 45 Elm St. in June of last year for $1,200 a month. She posted a $1,400 security deposit ($200 of which has since been returned) and also shelled out $1,400 to a Brooklyn-based real-estate broker for finding the apartment.

In June of this year, she learned the apartment was illegal when a city marshal and gas company representative came to remove the first-floor gas meter.

On July 12, the Buildings Department issued a vacate order, citing illegal apartments in the basement and attic, said court records. As a result, Ms. Aquino was forced to move.

Straniere said Ballester wasn't obliged to repay Ms. Aquino her rent because "no landlord-tenant relationship can exist where there is an illegal apartment." Consequently, "any agreement between the parties is unenforceable," he said.

The judge further noted that Ms. Aquino, like any other tenant, can access online city Buildings Department and Department of Housing, Preservation and Development records to determine if a premises is legal and whether it has been cited for any violations.

Yet, because the apartment was illegal, Ballester had no right to keep Ms. Aquino's security deposit, the judge reasoned. He also said the landlord was responsible for her moving fees because she had to relocate on short notice due to the apartment's illegal nature.

Straniere also took a bite out of the real-estate agent. He said Ms. Aquino was entitled to sue the broker for rent paid and the broker's fees for failing to ascertain whether the apartment was legal.

"As a broker, he is a 'licensed professional' charged with having greater knowledge of the real-estate industry than the general public and has a professional obligation to check ... governmental websites to insure that the representations of the landlord or seller are accurate and the premises are legal and can be used for the purpose their client is seeking their advice and assistance," wrote the judge.

The ruling could have far-reaching consequences.

While a Buildings Department spokeswoman could not immediately estimate the number of illegal apartments on Staten Island, sources said the number likely is fairly large.

Messages left Thursday at Ms. Aquino's current home in West Brighton and for Ballester were not immediately returned.