The fact that he didn't ejaculate will reduce the chance greatly, should he be HIV+ and not on treatment. (If he's not HIV+, the risk is obviously nil, and if he is but has been on treatment for at least six months, the risk also plummets to near zero.)
A modern blood test will give reliable results a month from the possible exposure you're concerned about.
If anything like this - unprotected sex with someone from a higher risk group / anal - happens again, you want to consider going to the nearest sexual health clinic or, out of hours, A&E and asking about 'PEP' - a month-long course of anti-HIV drugs that reduce the chance of becoming infected. As with the 'morning after pill', the sooner it's taken, the better and it's pointless after three days.