How did the panama canal territory become a possession of the US?

America sided with the panamanians to help them win their freedom from cuba