The Supreme Court is hearing arguements today in a case that straddles this issue.
Apparently a younger guy (17) in Arizona went off the deep end, and his parents tried to get him committed but couldn't because he wasn't deemed a threat to himself or others. He was convinced that his family were all aliens (the 3rd Encounter kind, not the illegal immigrant kind). A few months later he stole the family truck and drove it around and around one block with loud music blaring. Someone called the cops, and one officer responded. There was a gunfight and the officer was killed. There's no debate as to who did it, but the guy was pretty clearly not all there.
The court found him guilty, but the defense wanted him found guilty but insane so he could get the help he needed. Unfortunately, the court said that he may have been insane immediately before and immediately after killing the officer but not doing since he knew he was doing wrong because he later ran from the cops.
Here's the story:
http://news.yahoo.com/s/ap/20060419/...tus_insanity_2
Personally, I think that this particular set of circumstances is right on that fine line.