Texas, alone among the Confederate states, shared a border with a neutral country. Although Mexican president Benito Juárez favored the North, his opponents in northern Mexico, including Governor Santiago Vidaurri of Tamaulipas, encouraged trade with Texas and the Confederacy across the Rio Grande. A brisk commerce resulted in which Texas cotton bought much-needed foreign goods, including weapons and other military supplies. The sleepy Mexican coastal village of Bagdad grew temporarily into a bustling city, and Matamoros, sixty-five miles from the mouth of the Rio Grande, became the center of the trade. The Texas State Gazette reported in mid-1863 that Matamoros was "crowded with merchants and traders from all parts of the world" and that the sidewalks were "blocked up with goods." Unable to blockade the neutral Mexican coast, the Lincoln administration ordered Maj. Gen. Nathaniel P. Banks, commander of the Department of the Gulf at New Orleans, to interdict the lucrative trade between Texas and Mexico. On November 2, 1863, a 6,000-man invasion force from the Union Thirteenth Corps under Gen. Napoleon Dana raised the United States flag over the sand dunes at Brazos Santiago. The out-manned Confederates soon evacuated Brownsville, and by January 1, 1864, the federal troops had pushed up the Gulf Coast to Corpus Christi, Matagorda Island, Indianola, and Port Lavaca, and up the Rio Grande as far as Edinburg and Rio Grande City. Maj. Gen. John B. Magruder, who was in command of the Confederate District of Texas, dispatched Col. John S. Ford to South Texas to gather a force to resist the Union invasion.
In the meantime hundreds of Texas refugees, including many prominent Unionists, arrived in Brownsville. Provisional governor Andrew J. Hamilton established a provisional government, and Col. Edmund J. Davis and Lt. Col. John L. Haynes recruited Unionists, Confederate deserters, and Hispanics into the First and Second Texas Cavalry regiments. Judge J. B. McFarland organized a provisional court that met at the Brownsville Episcopal church, while other refugees such as federal district judge Thomas H. Duval and legislator John Hancock helped recruit troops for the federal army and attempted to convince Union authorities to invade the interior of the state. The refugees formed a chapter of the Union League of Texas-an auxiliary to the Republican party-that met every Saturday at Market Hall in Brownsville. With little actual soldiering to do, aside from an expedition into Matamoros to protect the United States consulate during fighting between Mexican factions, the federal soldiers spent most of their time fighting off dust storms and smallpox. One young officer recorded in his diary that "the days are dull, indeed, and we can find but little to do to beguile its tediousness."
By June 1864 Colonel Ford had collected his "Cavalry of the West," a motley assortment of 1,300 troopers, including old men and boys ineligible for Confederate conscription, Hispanics, deserters, outlaws, and mercenaries. Fortunately for the Confederates, General Banks, in preparation for the Red River expedition in Louisiana, had recalled more than half of the Union invasion force and ordered all of the captured territory evacuated except the area around Brownsville, Brazos Santiago, and Port Isabel. The withdrawal of Union forces disheartened the Texas refugees; Judge Duval sadly reported, "Texas is evidently abandoned for months to come . . . I am heartsick and weary." Advancing on the federals from the West, Ford's command won several sharp skirmishes against Yankee units that included the two regiments of Texas Unionists. Federal troops, unable to halt the Confederate advance, retired from Brownsville on June 29, and the refugees scrambled to safety across the Rio Grande. Many spent the last year of the war in New Orleans. By the end of September only a 950-man garrison remained at Brazos Santiago, where they stayed, eyed closely by a few Confederate troops, until a month after the Confederate surrender at Appomattox. On May 12, 1865, elements of two regiments of federal infantry made an ill-advised advance toward Palmito Ranch (see PALMITO RANCH, BATTLE OF), where they were routed by Ford and his cavalry the next day. The Confederates suffered only a few casualties, but they killed, wounded, or captured more than two-thirds of the Yankee force. The affair at Palmito Hill, the last land battle of the Civil War, ended the Rio Grande campaign.