An ex post facto defense is one that claims that an accused criminal is not guilty of the crime because the law that he or she is charged under is an ex post facto law. Ex post facto laws are prohibited by the Constitution of the United States.
An ex post facto law is one that was made after the commission of the act that the defendant is accused of. In other words, this is a law that is made after the action occurs, saying that that action was retroactively illegal. Such laws are prohibited by the Constitution because they are unfair. It is not right to prosecute someone for doing something that was not illegal at the time that they did it.
So, an ex post facto defense is one that says, in essence "I cannot be guilty of a crime because what I did was not illegal when I did it."