The process is quite involved, but note that an NTP sync is a conversation, and as you suspect, it needs to work out the round-trip time in order to effectively sync while taking into consideration how long packets take.
While the client may not know the time accurately when it requests a time update, it does know at least when it sent the packet. The server knows the exact time it receives a packet, plus the exact time it sends a reply. The client knows the intervening time between the time it sent a packet and the receipt of the reply.
So from these numbers it is straightforward to calculate the correct time, provided the delay is consistent across the conversation.
It isn't always consistent of course, which is why multiple servers are generally configured so that errors can be averaged out, along with the client keeping state tracking information so that it can ignore any crazy results.
Wikipedia is a good source for detail.