Stockton was appointed a midshipman in the U.S. Navy in September 1811, shortly after his 16th birthday, and served at sea and ashore during the War of 1812. After that conflict, Lieutenant Stockton was assigned to ships operating in the Mediterranean, in the Caribbean and off the coast of West Africa. He was the first naval officer to act against the slave trade and captured several slave ships. Stockton along with Dr. Eli Ayers of the American Colonization Society negotiated a treaty that led to the founding of the state of Liberia. One source describes that he "leveled a pistol at King Peter's head and thereby convinced the latter to sell some of his territory".[1]

During the later 1820s and into the 1830s, he primarily devoted his attention to business affairs in New Jersey. The birth of his son John P. Stockton, later also a U.S. Senator representing New Jersey, occurred during this time.

In 1838, Stockton resumed active naval service as a captain. He served in the European area, but took leave in 1840 to undertake political work. Offered the post of U.S. Secretary of the Navy by President John Tyler in 1841, he declined the offer, but worked successfully to gain support for the construction of an advanced steam warship with a battery of very heavy guns.

This ship became USS Princeton, the Navy's first screw-propelled steamer. The ship was designed by John Ericsson. Stockton commanded her when she was completed in 1843. The ship was armed with two long 225 pound wrought iron guns, called the "Peacemaker" and the "Oregon". Although he was the deviser of the defective gun, Captain Stockton was absolved of all responsibility for the February 1844 explosion of the gun, the Peacemaker, on board the ship. The explosion killed two cabinet secretaries and several others.[2]

Cleared by the court of any wrongdoing in the explosion incident, Stockton was sent by President James K. Polk to Texas. Stockton carried with him Polk's offer to annex Texas, sailing on the Princeton and arriving in Galveston. Stockton's observations while in Texas made him aware of the looming war with Mexico, a fact he communicated directly to Polk once he arrived back in Washington.[3] No vessel during the Mexican war was more useful than the Princeton in the Gulf of Mexico. The records of the Navy Department showed she performed more service than all the rest of the Gulf squadron put together.[citation needed]

On July 23, 1846 Commodore Stockton arrived in Monterey, California and took over command from the ailing Commodore John D. Sloat of the Pacific Squadron of U.S. naval forces in the Pacific Ocean. Commodore Sloat had previously raised the US flag, without resistance, at Monterey, but had no plan to conduct any further military operations on shore and once relieved, sailed home to the United States, leaving Commodore Stockton in command of all US forces. Stockton's command ship was the USS Congress and his combined fleet of three frigates with about 480 men each, one Ship of the line with about 780 men and up to four sloops with about 200 men each as well as three storeships made him the strongest force in California as well as the senior military commander. He was the main driving force in continuing to take possession of Alta California.

On August 11, 1846 Commodore Stockton marched on Pueblo de Los Angeles to meet in battle with General Castro's army. Upon learning of the imminent arrival of Commodore Stockton, Castro retired, leaving behind all his artillery and made off in the direction of Sonora. Immediately after these events Stockton dispatched a courier (the celebrated Kit Carson) to inform Washington of the proceedings and details of his conquest of California.

On December 6, 1846 Stockton learned that General Stephen Kearny had arrived in California with a small force and that he was besieged by vastly superior enemy forces at the Battle of San Pasqual. Kearny was among the wounded and in command of only 60 weary dragoons mounted on tired mules who were in a perilous position and under attack from a Californio-Mexican cavalry force under Andrés Pico. But for Commodore Stockton's immediate decision to take personal command of a relief column, the outcome could have been disastrous for Kearny.

Later, the combined forces consolidated control over San Diego, and in January 1847 won the minor skirmishes at the Battle of Rio San Gabriel and Battle of La Mesa taking back control of Los Angeles. Faced with the approximate 400 men under John C. Fremont's California Battalion as well as Stockton and Kearny's troops, the Californios sued for peace and signed the Treaty of Cahuenga, which ending fighting in Alta California. Stockton, as senior military authority and U.S. Military Governor of California territory, authorized John C. Fremont's appointment to succeed him as military governor and commander of the California Battalion militia force. When General Kearny finally arrived with orders to assume control of the temporary government Stockton turned over control to Kearny.

Stockton resigned from the Navy in May 1850 and returned to business and political pursuits. In 1851 he was elected as a Democrat from New Jersey to the United States Senate, where he sponsored a bill to abolish flogging as a Navy punishment. He resigned on January 10, 1853 to serve as president of the Delaware and Raritan Canal Company, a position he held until 1866.

Formerly Commodore Stockton Elementary School on Stockton between Clay and Pacific Streets was named after him. Stockton street in San Jose was named after him and his Garden Alameda San Jose neighborhood.