On August 5, 2008, Koster narrowly defeated State Representative Margaret Donnelly in the Democratic primary for the nomination for Missouri Attorney General. Koster won despite accusations that his campaign violated state law in raising money from multiple committees. He also survived the disclosure that he played a supporting role in a plagiarism episode that damaged Attorney General William L. Webster’s campaign for governor in 1992. Fresh out of law school, Koster worked for Webster, a Republican, as an assistant state attorney general. His campaign was not easily won because he had to overcome the label of "opportunist" as a result of switching parties during the '08 election. He then went on to defeat Republican State Senator Mike Gibbons in the general election, 52.83% to 47.17%. He was sworn in as attorney general on January 12, 2009, succeeding Jay Nixon.