As far as I know, if the trademark is registered by somebody else, then they can legally request you stop using it ( take you to court)..and the law is usually on the side of the person or persons who registered it. It doesn't matter if you were using it first..if it's registered, then it's the property of that person and can't be used without their permission, which is referred to as "infringement."..that's why trademarks are registered in the first place, as they usually are tied to a brand, product or individual and used as part of their business identity.
Flexagon is both right and wrong..
Right in that if you are the first one to use something as your trademark, but it is unregistered, then you can claim it as your own trademark, and request others not to use it..even take them to court. You need to use the letters "TM" after the mark, so as to let others know you are claiming the trademark as your own and are stating your rights of ownership of the same.
Wrong, however, in that if somebody else actually registers it legally, then it becomes their property and they can sue you on the grounds of infringement.
There's loads of sites out there that go into great detail on this topic..but here's one
that explains it clear enough. The main point about your case is you never used it publicly..or if you did, then it wasn't to any great extent. Meanwhile, this other business entity has gone and registered it, meaning they now have legal protection of that trademark..and it would be hard for you to prove it was yours in the first place, as you never registered it to begin with or used the letters "TM" after it.
It sucks, but you might want to think about changing it a little, so it sounds the same, but looks and is spelt differently. Or if it's just a image logo-type thing, then alter it enough so that it doesn't look like an obvious ripoff of the registered one. At least, that way, you could demonstrate to a court that you took active steps to not use the register trademark, which should count for something if it ever came to a court case.
Another thing is where the name is registered as a trademark and in which jurisdiction that registration is legally applicable. Basically, in the U.S, if you register a trademark, then it is legally covered through the nation. On the other hand, if you DON'T register your trademark and just use the letters "TM", then you are likely to only have a legal claim within your own state and not elsewhere.
Likewise, the same applies to its use globally..meaning if you just register it in your own country, then others could still use it in other countries, in which your own laws don't apply. You can register it worldwide, but I'm pretty sure that's an expensive procedure.
Regardless, Flexagon is right..you should seek legal advice..third-hand info, such as what we've told you here is all well and good, but you really need to speak to a legal professional about things like this if you're serious about it..after all, it's your rights and money we're talking about here..and you should seek the best advice you can when it comes to both.