Texas has been controlled by Spain , France , and Mexico before declaring its independence from Mexico in 1836 . Mexico controlled the territory until 1836 when Texas won its independence , becoming an independent Republic .