The most common reason for eviction is nonpayment of rent. A landlord can also evict a tenant for breaking a term of the lease, for violating a serious law (such as prostitution), or being a public nuisance. The landlord cannot evict without going to court, but generally will prevail if he can prove the grounds for eviction. Thus, the best way to stop an eviction is attempt to settle with the landlord, or, failing that, delay moving out.
Act on the notice to quit. A landlord cannot get a court involved in an eviction until after he has posted a notice to quit. This will set a date, usually five days to 30 days in the future, by which the tenant is expected to vacate. As the tenant, you are not obligated to move out by the date in the notice to quit, but should take it as a sign of the landlord's willingness to pursue an eviction. Take immediate steps to identify the problem and try to remedy the situation by paying owed rent or complying with the lease.
Sign a new lease. A landlord can serve a tenant with a notice to quit solely because the lease expired. Signing a new lease protects both the landlord and the tenant, and gives them an opportunity to reach an understanding on any aspects of the agreement that might have been in question.
Shift the blame. If the rental property is in bad condition due to the landlord's negligence, withholding rent is a valid means for the tenant to force correction of the situation. If not done correctly, however, it can also be a reason for a notice to quit to posted and eviction pursued. You must generally inform the landlord of your intent to withhold rent prior to actually doing so. Thus, if a notice to quit has been served or failure to pay, it's a good idea to get current on the rent (get a receipt) and then inform the landlord of your intent to withhold rent until the bad conditions are remedied, thus shifting the blame. To show you're really serious, you can make a complaint with the local housing authority or code enforcer.
Call the police if locked out. A landlord cannot lock you out of a rental property without a judicial eviction. If the landlord is taking steps to prevent your access to the property, you should call the police immediately.
Go to court. If the date on the notice to quit comes and goes with no change, the landlord will likely file a complaint, which will be served on the tenant with a summons to appear in court. Up until the day in court, the landlord and tenant can resolve their issues and go back to life as usual. At the hearing, the landlord will make their case for eviction, and at this point, it's usually difficult for a tenant to defeat the eviction proceedings without strong documentary evidence and/or witnesses that refute the landlords claims.
Extend your stay. Upon being evicted by the court, a tenant usually has up to five days to vacate the premises. You can ask the court for up to six months through a formal "stay of execution," though the decision is at the judge's discretion. If the eviction was for failure to pay rent, the tenant can get an extra three months' stay if he posts all back rent with the court.