First of all: the entire situation seems quite a mess; more about this towards the end of this answer.
Yet, given the somewhat limited information in the original post, I'm surprised by the very clear stance that some of the other answers take on the situation.
Contributions and authorship in mathematics
It is certainly not true that contributing a technique or insight or result or proof is always considered to warrant co-authorship in mathematics. One can frequently read passages in math papers that say something like "We are grateful to John Doe for providing us with a proof of Theorem 3.5" or "We are indepted to Jane Doe for communicating Counterexample 4.3 to us (private communication)".
Like WhatTheDuck says in their answer, the crucial question is how "significant" OP's contribution was. But in contrast to WhatTheDuck I find it impossible to determine this from the information given in the question. The main reason why I find this impossible is that significance is highly context-dependent. It's very easy to imagine two different papers A and B of similar quality und relevance and a theorem which would be a very significant contribution in paper A but only a nice-to-have in paper B.
One thing to keep in mind here is that authors are listed alphabetically in papers in (pure) mathematics. There is no concept of a "first author" or "main author".
So if, say, mathematician A develops a deep and lengthy theory in a paper and mathematician B informs them about a theorem which provides some additional context but which is in no way essential for the theory, then adding B as a co-author of the paper would strongly misrepresent the contributions of A and B. In this case it is completely common that A is the sole author of the paper and only thanks B somewhere in the paper.
From the description in the question it seems impossible to say how significant OP's contribution was in the context of this paper. So I don't think we can judge whether OP was right to insist on being a co-author.
Two more comments:
Whether OP has written the section themselve is irrelevant for the question (although I find it quite weird that the colleague explicitly asked OP to do the writing). Most likely, it will actually be quite difficult (even for the OP and their colleague) to clearly determine how much of the section (in the version that finally made it into the paper) was written by the OP, since the colleague apparently made some adjustments - since it's not even clear what precisely "writing" means in the context of writing a paper.
Even knowing the degree of novelty of the techique developed by the OP would not suffice to judge how significant OP's contribution was. It is absolutely possible to use a highly novel and innovative technique to make a contribution to a paper which adds, for this paper, only minor or peripheral insights.
(The technique might of course still be of very significant use in another paper.)
All this said, let me stress again that I'm not saying that OP doesn't deserve authorship in this situation. I'm merely saying that, given the information in the question, it is impossible to judge whether or how much OP deserves to be an author in this situation.
Social aspects
Much more worrisome than the authorship question at hand, is, from my perspective, how the situation evolved at a social level. Person A believing that they should be a co-author while person B disagrees is one thing - but going from there to a full-grown argument, summoning "lines of authority" and the like is something very different.
General advice
I think we can't say whether OP was right to insist to be listed as a co-author. I'm also not sure we can give good advice regarding OP's relationship with their colleague, as their seems to be a lot of frustration involved (possibly on both sides) and we don't know much about the background.
Yet, there is one generic piece of advice which works, in my experience, quite well when it comes to authorship in mathematics (and a lot of mathematicians seems to follow it, be it consciously or only intuitively):
But the bar of what constitutes a "significant contribution" quite high when it comes to the question whether you should be a co-author somewhere.
But the bar much lower when it comes to the question whether someone else should be a co-author of one of your papers.
When mathematicians interact who follow those guidelines, it regularly comes to situations where someone suggests to "remove my name from the paper because I have not contributed enough to be an author" or where someone says "I think you should be a co-author of this paper" and the other person replies "probably not". Obviously, those disagreements are much easier and much more pleasant to resolve than the one described by in the question.