When Andrew Jackson ran for president in 1828, his opponents tried to label him a "jackass" for his populist views and his slogan, "Let the people rule." Jackson, however, picked up on their name calling and turned it to his own advantage by using the donkey on his campaign posters. During his presidency, the donkey was used to represent Jackson's stubbornness when he vetoed re-chartering the National Bank.
The first time the donkey was used in a political cartoon to represent the Democratic party, it was again in conjunction with Jackson. Although in 1837 Jackson was retired, he still thought of himself as the Party's leader and was shown trying to get the donkey to go where he wanted it to go. The cartoon was titled "A Modern Baalim and his Ass."
Interestingly enough, the person credited with getting the donkey widely accepted as the Democratic party's symbol probably had no knowledge of the prior associations. Thomas Nast, a famous political cartoonist, came to the United States with his parents in 1840 when he was six. He first used the donkey in an 1870 Harper's Weekly cartoon to represent the "Copperhead Press" kicking a dead lion, symbolizing Lincoln's Secretary of War Edwin M. Stanton, who had recently died. Nast intended the donkey to represent an anti-war faction with whom he disagreed, but the symbol caught the public's fancy and the cartoonist continued using it to indicate some Democratic editors and newspapers.
Later, Nast used the donkey to portray what he called "Caesarism" showing the alleged Democratic uneasiness over a possible third term for Ulysses S. Grant. In conjunction with this issue, Nast helped associate the elephant with the Republican party. Although the elephant had been connected with the Republican party in cartoons that appeared in 1860 and 1872, it was Nast's cartoon in 1874 published by Harper's Weekly that made the pachyderm stick as the Republican's symbol. A cartoon titled "The Third Term Panic," showed animals representing various issues running away from a donkey wearing a lion's skin tagged "Caesarism." The elephant labeled "The Republican Vote," was about to run into a pit containing inflation, chaos, repudiation, etc.
http://www.democrats.org/about/donkey.html