Hello there,
I totally agree with Katya's explanations and examples.
Both sentences are correct, the second choice is used in the case of emphasis.
More examples:
Are you sure about seeing your teacher ?
YES! I DID see him in the bus.
***
Are you kidding me?
NO, I swear, I DID break up with her!
***
Did you close the window? Are you sure?
YES, I DID close it.