Texas could be considered to have been a country for a very brief period of time, specifically from 1836, when it won its independence from Mexico, to 1845, when it became the 28th state in the union. It seceded from the United States during the Civil War, but affiliated itself with the Confederate States of America. That nine year period, then (1836-1845) is the only period during which Texas could be said to have been its own country. The Texas Revolution, which saw the territory's population wage its war of independence from Mexico, resulted in its own Declaration of Independence in 1836, after which it became known as the Republic of Texas. Following its defeat of the Mexican forces of Santa Anna, it even negotiated its own treaty with the Mexican government.
What transpired next was known as the Texas Archive War, the republic's own little civil war between advocates of continued political independence, led by Mirabeau Lamar, and advocates of joining the United States, led by Sam Houston. In the end, fear of continuing Mexican Army incursions and the risk of reoccupation by Mexico convinced most Texans to cast their lot with the United States.