The problem is not your ability to write code - the CTO even admits as much when he says he needs you now but wants to replace you later. Your code is desperately needed. But I don't really care about this.
Assuming a normal situation, the company is yours and your co-founder's (by ownership), and the CTO likely has a small amount of equity (relative to yours). In an early stage company that hasn't yet raised money, your company is basically an extension of yourself. You don't have responsibilities to shareholders or employees because you don't have either yet. You have a responsibility to yourself and your vision. The CTO did not found the company and that alone tells you that you have some amount of vision, ability, or ability to take advantage of chance that he did not have.
If you want to remain involved in the company, and it seems that you do and should, then you need to clarify for the CTO where the boundaries of his responsibilities lie. His job is not to ask you to quit, and he may be beyond the point where you can continue working with him (or not - I don't know enough detail). But if he is to continue working for you (and do recall that he works for you at your pleasure), he needs to focus on solutions that don't involve him trying to fire you.
Most founders don't end up coding very much after their companies grow, and the CTO may be hopeful to get more experienced programmers working for the company. But there are about 10,000 miles in between "we should hire people with deep experience in X" and "I want you to leave the company." The latter is a political gambit that needs to be dealt with after careful consideration in a way that shows teeth.