Can the landlord lock me out and keep my belongings inside

I moved into an apartment this August. I was staying with the actual tenant(who had entered a one -year contract with the landlord in January 2015) and since then splitting the rent with him. But I didn't know this person already had some arrears with the landlord. Now in December I found a new place and was about to move out of my current apartment yesterday and the landlord is refusing to let me leave. He wants me to pay the full rent money of December(we've already paid half of it) before I leave. But the actual tenant wishes to stay further in the apartment and assured the landlord that he'll pay the rest of the money in two days time. But the landlord is refusing to let me leave till he gets his money. He has threatened to lock me out of the apartment and said he will not let me take my things. Last month the landlord had come into our apartment when my flatmate was not there and took his laptop as some kind of security and left. What should I do? Do I have any legal binding to this apartment as I have not entered any legal contracts with the landlord or the actual tenant? Can the landlord press trespassing charges against me?