Robert Bryan was nearly forced out of his West 20th Street apartment. View Full Caption DNAinfo/Mathew Katz

CHELSEA — When Robert Bryan got a letter this spring saying he needed to move out of his $700-a-month, rent-stabilized apartment, he thought he had no choice.

The letter was from Blesso Properties, the owner of Bryan's building at 234 W. 20th St., and it accused him of bringing bedbugs into the building, where he had lived since 1965.

The 78-year-old faced rents of $2,000 or higher if he had to move elsewhere in the neighborhood.

Bryan was initially intimidated by the letter, but he got advice from neighborhood activist Richard D'Onellas of the McManus Democratic Club, who helps tenants navigate the system. With his help, Bryan realized the notice was not official and that he could fight it.

"Without [D'Onellas], I wouldn't have the faintest clue what to do and I would have left," Bryan said.

Bryan's apartment was repaired and fumigated after a few quick phone calls to city agencies and he still lives there today.

According to a report by the New York City Rent Guidelines Board, a total of 7,597 rent-stabilized apartments were deregulated in 2013. Most of them changed status because the tenants moved out, but landlords are only legally authorized to deregulate if they can prove they have renovated or carried out improvements since the tenants left.

MORE IN REAL ESTATE NEWS:

► Find Out if Your Market-Rate Apartment Should be Rent-Stabilized

► How to Discover Who Used to Live in Your Apartment

► How to Spot an Apartment Rental Scam

With the help of experts, DNAinfo New York has a compiled a basic guide to staying in your apartment if your landlord is trying to get you out.

Evictions Must Come from a Judge

"There are a lot of notices that you can receive — and tenants see a notice of termination and think there's nothing you can do," said Chris Schwartz, a supervising attorney at MFY Legal Services that provides free legal assistance to tenants in need. "That's really just the beginning of the case."

In New York City, landlords must obtain a warrant of eviction from a judge to legally evict someone if they have a lease or have lived there for more than 30 days. You should get notification if an eviction case against you is pending and have an opportunity to see a judge.

Even if you are in a rent-stabilized unit, there are some ways you can be legally evicted, such as if you don't pay your rent or if a landlord can prove that the apartment is not your primary residence.

For other issues, landlords can initiate a "holdover procedure," Schwartz said, which involves a tenant creating a nuisance, such as hoarding possessions, creating smells, attracting vermin or unsanitary conditions, or breaching the terms of a lease.

"Nuisance is something we tell owners to keep an eye out for," said Vito Signorile, who represents landlords as part of the Rent Stabilization Association. "If it goes on for an extended period of time, or becomes an issue for other tenants, we encourage action to be taken."

Even if you are served an eviction notice, you have 72 hours before you have to go — meaning you can still appeal the decision before a judge. Any authentic eviction warrant will have a letterhead from New York City Housing Court and a judge's name and contact information.

Call 311 and Get an Inspector

Even if your landlord isn't trying to formally evict you, you may be facing run-down conditions. Landlords may neglect necessary fixes to apartments if they want a tenant to leave. Recently, tenants accused real estate scion Jared Kushner of doing just that to people living in an East Village apartment he owns.

Under city law, it's the landlord's responsibility to make sure your apartment is safe, clean and well maintained and has heat, hot and cold water and good lighting. Landlords must also paint the apartment every three years.

If your apartment is in need of repairs, notify your landlord in writing — either through email or certified mail. It's also a good idea to take pictures or keep a record of things like temperatures in your apartment if the heat isn't working.

If they don't respond, a call to 311 can get an inspector to the building to give them a little encouragement.

Don't Take Harassment

Landlord harassment can take many forms. Schwartz said he's seen an emergence of "relocation experts" — typically real estate brokers — who tell rent-controlled tenants that they have to leave because their building was sold.

"That's insane," he said. "A rent-regulated tenancy doesn't terminate when ownership changes, but the average person thinks they have to leave their home."

Harassment also includes tacking superfluous fees onto a tenant's rent bill — including things like legal fees and late charges when they don't belong.

Luckily, both HPD and New York State Homes and Community Renewal will investigate and deal with tenant harassment. HPD will issue fines of thousands of dollars if harassment is found and HCR will schedule face-to-face conferences to resolve the issues.

If all else fails, tenants can go to housing court to get injunctions against harassing behavior.

Last Resort: Go to Court

Filing a housing part action — which could force a landlord to make repairs or stop harassment — costs only $45. People who are living on fixed incomes can also have the fees waived by filing a Poor Person's Relief Form.

You can ask for a court-ordered inspection as well, which often spurs landlords into action.

Staff at Housing Court at 111 Centre St. are typically helpful to people confused by the process.

"There's a lot of help that can be found at 111 Centre Street and not many people know about it," D'Ornellas said.

While going to court could seem like a headache, it could be worth it to keep your rent-stabilized apartment.

"You're talking about a roof over your head," said D'Ornellas. "If you're in a situation where you're going to be thrown out or you're unsafe, that's worth the hassle."