Cooper supported the Mexican–American War; with many other Southerners, he believed that the US could gain territory for the expansion of slavery. He helped to raise a regiment, the 1st Mississippi Rifles. He served as a captain under the command of Colonel Jefferson Davis, participating in the battles of Monterrey and Buena Vista. He was cited for bravery and gallantry at the Battle of Monterrey.