Updated

Often trading personal insults, Alan Keyes (search) and Barack Obama (search) bickered over everything from broad government philosophy to details of policy on education and gay marriage Tuesday evening in the third and final debate of their Senate race.

"I know that Senator Obama sometimes has trouble getting from A to B," Keyes said at one point.

"I think your logic was not that complicated. It's just wrong," Obama shot back moments later.

The debate included a lengthy discussion of the role of government, with Keyes suggesting government generally should leave poverty and other social ills to religious organizations.

"I am not obsessed with government, and I think that's the difference between me and Barack Obama," said Keyes, a Republican and former ambassador to the United Nations.

But Obama, a Democratic state senator, maintained that government must do its best to help when it can.

"When a child doesn't have health insurance, they don't need a lecture. They need health insurance," he said.

For the first time in the three debates, Obama at times found himself on the defensive.

He struggled to explain what in his religious beliefs leads him to oppose gay marriage. Keyes hammered him over opposing school vouchers while sending his children to private school. Asked whether he opposes drilling for oil in the Alaska National Wildlife Refuge, Obama first said no, then laughingly corrected himself to make clear that he opposes drilling.

Both men oppose gay marriage, but the subject produced some of the debate's most confrontational moments.

Obama criticized Keyes' argument that the children of gay couples, if born from artificial means and kept in the dark about their biological parents, could later end up unknowingly having sex with a relative. He claimed the argument was a subtle attempt to link homosexuality with incest and said the same logic could be used to oppose adoption.

Keyes accused Obama of denying his logic because he didn't like the conclusion.

"If you can't know who your sisters and brothers are, there is no way you could avoid having sexual relations with them," he said.

The two are vying for the seat being vacated by Republican Sen. Peter Fitzgerald.