With 78 percent of precincts reporting, O'Donnell had 54 percent to 46 percent for Castle, a former two-term governor and the longest serving congressman in Delaware history.
While attracting enough GOP conservatives to defeat Castle, a leader of Republican moderates in Congress, O'Donnell will have a hard time defeating Democrat Chris Coons in November for the Senate seat vacated by Joe Biden after he was elected vice president.
But voters nevertheless took their chances on O'Donnell, who characterized Castle as a liberal who sides with big-spending Democrats more than he does with fellow Republicans.
"I think Castle is too liberal," said Robert Manning, 56, a design engineer from Georgetown who voted for O'Donnell. "I think Washington has done enough damage with all this stimulus spending over the past 18 or 19 months," Manning added. "It's time to get back within our budget."
O'Donnell, who hasn't had a steady job in years but has instead made an avocation of running for Senate, finally won after two failed Senate bids. She came in last in a three-way GOP primary in 2006 and lost badly to Biden in 2008, when she won the endorsement of state GOP convention delegates but received virtually no help from the party.
But the Tea Party Express bolstered O'Donnell's long-shot bid this year by pledging $250,000 to run television and radio ads on her behalf.
O'Donnell and her staunchly conservative supporters characterized Castle as a liberal who often votes with Democrats in Congress while masquerading as a GOP conservative. In their words, Castle is a "RINO," a "Republican in Name Only."
They also suggested that Castle, 71, was so frail that he might die before finishing his Senate term, that he might switch parties, and that he was cheating on his wife with a man.
While ignoring O'Donnell for much of the campaign, Castle and state Republican Party eventually fired back with attack ads of their own, criticizing O'Donnell, 41, for lying about her education and record, leaving a trail of unpaid bills that included unsettled campaign debts, tax liens and a default on her mortgage, and using campaign finances for personal expenses. The GOP also filed a complaint with the Federal Elections Commission accusing O'Donnell of illegally colluding with tea party supporters.