After ejaculation, sperm is left inside the penis in the urethra. Later, when he became aroused (and was rubbing you) his penis will secrete pre-cum which (especially having ejaculated recently) is loaded with sperm, which can be left at the opening to your vagina, and then CAN swim all the way to your uterus.
Note that this method is not a great way to get pregnant, but it is certainly possible.
If it has been less than 72 hours since this happened, it would be a good idea to get Plan B - the emergency contraceptive (also known as the morning after pill).
Anyone 17 or older can buy it at any pharmacy counter. Either you or your boyfriend. (I would suggest that your boyfriend pay, but that is up to you.) You may also be able to get it for less at a Planned Parenthood in your area.
In the future, have your boyfriend use a condom 100%, or you can go on the BC pill. That you also can get at Planned Parenthood.