I had the exact same problem on my 2004 xterra several years ago. I won't say this is 100% accurate...but it is pretty close ...I'd love to have someone definitively say something like "that clicking noise is the ________ doing _______ and that loud thud/clunk is when the ________ finally does __________, but no one has told us that when we've asked.
The stock auto locking hubs lock into 4wd (meaning the hub with the tire engages with the CV axles) when there is a torque applied which catches the 4WD hub onto the inner locking ring ("Fixed cam assembly"). If one side happens to be stuck in the locked position, the road pushes on the tire which catches the fixed cam assembly and the CV axle, which then applies torque into the differential which can then apply torque to the opposite side tire. I then got a "click...click...click...click...click...CLUNK" noise, which was the GOOD side halfway locking in. Eventually it had a loud clunk and it was good until I came to a stop. Maybe I don't understand the 100% explanation since we have open differentials (or my front USED to be open Lokka for the win!!!) so maybe the torque shouldn't carry from one side to the other...but this was 100% exactly what I went through.
The big take away is that what you describe sounds like 100% locking hubs. New manual locking hubs will fix this (I got mile markers). The loud CLUNK usually comes from your GOOD side...as was the case with mine...the GOOD side trying to lock in since the BAD side was getting stuck and sending torque backwards through the drive train. The clunk came from the LEFT tire because my RIGHT auto hub was bad. I swapped my left hub with 2 different junk yard hubs until my buddy (xterror04 on here and xterrnation.org) watched my CV axles as I drove slowly in 2wd and noticed I had one CV axle still getting stuck and rotating.