The term Whig originates from the Exclusion Bill crisis of 1678-1681. The Whigs were those who supported the exclusion of James II and VII from the thrones of England, Ireland and Scotland (the "Petitioners") and the Tories were those who opposed it (the Abhorrers). Both names were originally insults: a "whiggamor" was a cattle driver, and a "tory" was an Irish term for an outlaw.
Generally, the Tories were associated with the landed gentry and the Church of England, while Whigs were more associated with the great noble houses, the moneyed interest, and religious dissent. Both were still committed to the political system in place at that time. Neither group could be considered a true political party in the modern sense.
In the early Hanoverian period, the Whigs became the dominant party of government, due to the Tories' association with Jacobitism. During this long period, the Tories practically died out as an active political force. This changed during the reign of George III, who hoped to restore his own power by freeing himself from the great Whig magnates, and a new Tory party arose – created largely by former moderate Whigs like William Pitt the Younger. In British North America, Whiggery was closely identified with the Patriots. The flirtation of the Whigs (and their leader, Charles James Fox) with Jacobinism in the early years of the French Revolution, as well as their strong support for Catholic emancipation, left them largely out of power for the period between 1783 and 1830.
In 1830, the Whigs finally returned to power, and the administration of Lord Grey accomplished a number of important reform measures – most notably the parliamentary Reform Act 1832 and the abolition of slavery. The Whigs, however, remained a largely conservative party (as did the Tories), and generally opposed any further changes to the British governmental system. It was around this time that the great Whig historian Thomas Babington Macaulay began to promulgate what would later be coined the Whig view of history, in which all of English history was seen as leading up to the culminating moment of the passage of Lord Grey's reform bill. The Whig view led to serious distortions in later views of 17th century history, as Macaulay and his followers attempted to fit the complex factional politics of the Restoration into the neat categories of early 19th century political divisions.
The Liberal Party (the term was first used officially in 1868, but it had been used colloquially for decades beforehand.) arose out of a coalition between Whigs, free trade Tory followers of Robert Peel, and left wing Radicals which was first created, tenuously under the Peelite Lord Aberdeen in 1852, and put together more permanently under the former Canningite Tory Lord Palmerston in 1859. Although the Whigs at first formed the most important part of the coalition, the Whiggish elements of the new party progressively lost influence during the long leadership of the Peelite William Ewart Gladstone, and many of the old Whig aristocrats broke from the party over the issue of Irish home rule in 1886 to help form the Liberal Unionist Party. The Unionist turn to protection in the early twentieth century, however, (inspired by the Liberal Unionists' own leader, Joseph Chamberlain, probably the least Whiggish character in the party) further alienated the more orthodox Whigs, however, and by the early twentieth century whiggery was largely irrelevant and without a natural political home.