If we are talking about a 3rd gen, and you unplug the car battery and take the key and insert it and turn it in the rear hatch door key lock to unlock position, it will unlock the door. So it's a mechanical connection that doesn't need power (there is a small lever to unlock the door latch). If it doesn't, then it there is something mechanical not in place.
Anyway...
But if the problem is when you press the lock/unlock master switch on the driver's door or the remote, then then it is probably in the circuit that opens the rear hatch.
Not sure what year 3gen the OP has, but here is a picture of the wiring diagram (diagram without wireless door lock control) of where the motor takes power to lock/unlock the rear hatch.
The command comes from the driver's cowl junction/fuse box (Toyota names this box on the diagrams - BODY ECU which can be confusing, because the actual body ecu engine controller stays under the passenger airbag, but this door issue is in the junction box on the driver's side).
Inside there are a pair of small relays that usually fail on these Runners and have to be replaced. If you notice that the driver door's manual lock levers don't move up/down when you press the master lock switch, then the problem is in that fuse box's relays.
There are a few threads on this subject. Easiest way to fix this problem is to replace the junction box preferably with new as used one can have the reach the same problem sooner. It takes about 30-60 minutes to install.
here is one thread -
http://www.toyota-4runner.org/3rd-gen-t4rs/236735-doors-wont-lock-write-up.html
and this one is with pictures -
http://www.toyota-4runner.org/3rd-gen-t4rs/44772-power-locks-2.html