Taney was born of a wealthy slave-owning family of tobacco farmers. He was admitted to the bar in 1799 and as a Federalist served (1799–1800) one term in the Maryland house of delegates. He temporarily broke with the Federalist leadership over the party's opposition to the War of 1812, but he gained control of the Federalists in Maryland and in 1816 was elected to a five-year term in the state senate. Having built up a large practice, he moved (1823) from Frederick to Baltimore.
In 1824 he permanently abandoned the Federalists to support Andrew Jackson. President Jackson appointed (1831) Taney to the post of Attorney General to assist in the struggle with the Bank of the United States. Taney wrote much of Jackson's message vetoing (1832) the act that rechartered the bank, and, when Louis McLane and William J. Duane refused to withdraw federal funds from the bank, Taney was appointed (1833) Secretary of the Treasury and effected the withdrawal.