Whigs came from opposition -- specifically, opposing Andrew Jackson, after he decisively beat John Quincy Adams in 1828 and easily won reelection in 1832. Jackson stood for the common man, state power, and the power of the executive branch (like most presidents). Adams’ supporters took the name of Whig, since it was often used to describe people who supported the colonies in the Revolutionary War.
The 1824 election itself featured four candidates: Adams, Jackson, Henry Clay, and William Crawford. Jackson got the most electoral votes and popular votes*, garnering 99 of the former and 41% of the latter, but since no one got a majority of the 261 votes then in the College, the election was thrown into the House of Representatives. Since Jackson got the most electoral votes and won the most states, one would think that he would eventually win there, and according to his supporters, the fact that he didn’t was a travesty.
Clay came in fourth, so he wasn’t an option for the House, which was required to pick one of the top three candidates. Since Clay had a lot more common politically with Adams than Jackson, he told his supporters to vote for Adams, who subsequently appointed him Secretary of State. That was later termed the ‘corrupt bargain’, and doubtless was a factor in his 12-point loss four years later.
Initially, Adams’ supporters were simply known as Adams men, and Jackson’s frequently as Jacksonians (they later became known more as Democrats), but soon the former assembled a coalition called the National Republicans, reflecting their focus on national unity and federally financed infrastructure development. National unity was something of a concern still in American politics, since in 1824 the four candidates had won little more than their own regions.
(Adams of Massachusetts, Jackson of Tennessee, Crawford of Georgia, and Clay of Kentucky)
After two successive losses against Jackson, the National Republican Party collapsed, and rebranded itself as the Whigs, with rather more success, electing William Henry Harrison in 1840 and Zachary Taylor in 1848; both died in office.