Lawyer and politician
Kennedy enjoyed politics more than law (although the Union Bank was a prime client), and left the Democratic Party when he realized that under President Andrew Jackson it came to oppose internal improvements. He thus became an active Whig like his father-in-law and favored Baltimore's commercial interests. He was appointed Secretary of the Legation in Chile on January 27, 1823, but did not proceed to his post, instead resigning on June 23 of the same year. He was elected to the Maryland House of Delegates in 1820 and chaired its committee on internal improvements, championing the Chesapeake and Ohio Canal so vigorously (despite its failure to pay dividends), that he failed to win re-election after his 1823 vote for state support.
In 1838, Kennedy succeeded Isaac McKim in the U.S. House of Representatives, but was defeated in his bid for reelection in November of that year. Meanwhile, in 1835, Kennedy was among the 10 Baltimoreans who attended a railroad meeting in Brownsville, Pennsylvania, where he delivered a very well-received address urging completion of the B&O Railroad to the Ohio River valley (rather than to Pennsylvania canals, which fed Philadelphia rather than Baltimore). Kennedy was also on the 25-man committee that lobbied the Maryland legislature on the B&O's behalf and ultimately secured passage of the "Eight Million Dollar Bill" in 1836, which led to his becoming a B&O board member the following year (and remained such for many years). When the B&O chose a route westward through Virginia rather than the mountains near Hagerstown, Maryland in 1838, Kennedy was in the B&O's delegation to lobby Virginia's legislature (together with B&O President Louis McLane and well-connected Maryland delegate John Spear Nicholas, son of Judge Philip Norborne Nicholas, a leader of the Richmond Junto) that secured passage of a law authorizing a $1,058,000 (~$31.6 million in 2025) subscription (40% of the estimated cost for building the B&O through the state). However, the B&O's shareholders would reject the necessary Wheeling subscription because of its onerous terms, and Kennedy would again take up his pen in the B&O's defense against criticism by Maryland Governor William Grason.
Kennedy won re-election to Congress in 1840 and 1842; but, because of his strong opposition to the annexation of Texas, he was defeated in 1844. His influence in Congress was largely responsible for the appropriation of $30,000 to test Samuel Morse's telegraph. In 1847, Kennedy became speaker of the Maryland House of Delegates, and used his influence to help the B&O, although by the late 1840s it was caught in a three-way controversy with the states of Pennsylvania and Virginia as to whether the B&O's terminus should be Wheeling, Parkersburg or Pittsburgh. After an acrimonious shareholders meeting on August 25, 1847, the B&O affirmed Wheeling as its terminus, and finally completed track to the city in 1853.
Meanwhile, President Millard Fillmore appointed Kennedy as Secretary of the Navy in July 1852. During Kennedy's tenure in office, the Navy organized four important naval expeditions including that which sent Commodore Matthew C. Perry to Japan and Lieutenant William Lewis Herndon and Lieutenant Lardner Gibbon to explore the Amazon.
Kennedy was proposed as a vice-presidential running mate to Abraham Lincoln when Lincoln first sought the Presidency of the United States, although Kennedy was ultimately not selected. Kennedy became a forceful supporter of the Union during the Civil War, and he supported the passage of the Emancipation Proclamation. Later, since the proclamation did not free Maryland slaves because the state was not in rebellion, he also used his influence to push for legislation in Maryland that ultimately ended slavery there in 1864.
In 1853, he was elected as a member to the American Philosophical Society.