The annexation angered Mexico. Texas had been a part of Mexico until 1836 when the Texans declared their independence following their own war with Mexico. Mexican leaders warned Texans that annexation with the US would lead to war. Six days after the joint resolution passed Congress, Polk declared in his inaugural address that only Texas and the United States would decide the question of the annexation of Texas.
After the Texas annexation, Polk turned his attention to California. He wanted to acquire the territory from Mexico. He was especially interested in San Francisco Bay as an access point for trade with Asia. In 1845, he sent diplomat John Slidell to Mexico to offer to purchase California and New Mexico for $24–30 million. When the Mexicans learned that Slidell was there to purchase additional territory and not to offer compensation for the loss of Texas, they refused to recognize Slidell's credentials. In January 1846, under the auspices of protecting Texas and to increase pressure on Mexico to negotiate, Polk sent troops under General Zachary Taylor into the area between the Nueces River and the Rio Grande. This was territory that was claimed by both the U.S. and Mexico.
Prior to Texan independence, the Nueces River was recognized as the northern boundary of Mexico. Spain had fixed the Nueces as a border in 1816, and the United States ratified it in the 1819 treaty in which the United States purchased Florida and renounced claims to Texas. After Mexico's independence from Spain, American and European cartographers still fixed the Texas border at the Nueces. When Texas declared its independence, however, it claimed as its territory an additional 150 miles of land, to the Rio Grande. With the annexation of Texas in 1845, the United States adopted Texas's position and claimed the Rio Grande as the border.
Slidell returned to Washington in May 1846, having been rejected by the Mexican government. Polk interpreted this treatment of his diplomat as an insult. In Polk's mind, this itself was ample cause of war. He prepared to ask Congress for a declaration of war on this ground alone. However in the meantime, Taylor crossed the Rio Grande after some of his men were attacked at the river. Taylor briefly occupied Matamoros and his forces prevented ships from entering the port there. A few days before Polk intended to make his request to Congress, he received word that Mexican forces had crossed the Rio Grande area and killed eleven American soldiers in the disputed territory. Polk decided to make this his "casus belli" (cause for war).
Polk's critics alleged that he had been dishonest on two grounds. Firstly, they disputed whether on not Polk had the authority to send the Army to Mexico in the first place, or whether he needed Congressional approval to do so. The second issue concerned whether the army that Polk sent had proper cause to enter Mexico once they were there.
The Constitution was unclear on the first of these issues. It gave Congress the power to declare war, while making the President the Commander in Chief. In 1827, the US Supreme Court ruled in the case Martin v. Mott that it was constitutional for Congress to vest the president with the discretionary authority to decide whether an emergency had arisen and to raise a militia to meet such a threat of invasion or civil insurrection.
Polk addressed Congress on May 11, 1846. In his speech, he told Congress: "Mexico has passed the boundary of the United States, has invaded our territory and shed American blood upon the American soil." Polk claimed the move was a defensive measure. Expansionists supported his action. But some Whigs said that the movement was an invasion of Mexico rather than a defense of Texas. On May 13, Congress declared war, with a vote of 40-2 in the Senate and 174-14 in the House.
A number of Whig members of Congress, including Illinois Congressman Abraham Lincoln, challenged Polk's version of events. They were in the minority, and Congress overwhelmingly approved the declaration of war. Many Whigs feared that opposition would cost them politically by casting themselves as unpatriotic for not supporting the war effort. In the House, antislavery Whigs led by John Quincy Adams voted against the war.
Ohio Senator Tom Corwin accused Polk of involving the United States in a war of aggression. Senator John C. Calhoun of South Carolina abstained from voting. He predicted, correctly, that the war would aggravate sectional strife.
Lincoln, who was then a freshman Whig Congressman, questioned whether the "spot" where blood had been shed was really U.S. soil. On December 22, 1847, he introduced what became known as the "Spot Resolutions". Congress never voted on these, and Lincoln's action earned him a derisive nickname, "spotty Lincoln," by one Illinois newspaper.
Other prominent citizens expressed concern about the war, particularly in New England. Henry David Thoreau refused to pay his $1 Massachusetts poll tax because he believed the war an immoral advancement of slavery. Former President John Quincy Adams called the war a southern expedition to find "bigger pens to cram with slaves." Charles Sumner, a noted abolitionist, also condemned the war. The Massachusetts state legislature resolved the war an unconstitutional action because it was initiated by order of the President with the "triple object of extending slavery, of strengthening the slave power and of obtaining the control of the free states."
The war ended in 1848 with the Treaty of Guadalupe Hidalgo. The war had serious consequences for Polk and the Democrats. The Whigs went into the next election denouncing the war as an immoral act of aggression carried out through abuse of power by the president. In the 1848 election, however, the Whigs nominated General Zachary Taylor, a war hero, and celebrated his victories. On the one hand, the Whigs could be seen as supporting the soldiers who fought in the war, while opposing the politician who had sent those men to war.
The strain of managing the war effort caused Polk's health to declined toward the end of his presidency. He died less than two months after leaving office.