Feeling of having to pee during sex?

I had sex for the first time yesterday night. It was okay. I had quite a bit of pain but it got better towards the end. What I noticed though was the feeling that I had to pee. Why is this?