If you agreed to a non-aggression pact (if you can walk in their territory without declaring war then you did), then you're stuck for 99 turns. Once it expires you can declare war to your heart's content. Lots of stuff is recalculated on load, so you might save and reload to see if it 'forgets' your treaty effectively letting you out of it.
Note: I don't think there's an easy / proper (overview screen) way to see the status or remaining time of any treaties, nor the full map of relations. Kind of similar to the missing city information (# of each type of building, total upkeep costs and generation in addition to net, etc).