Who is responsible for avoiding collisions on the ground; the pilot or the air traffic controller?
At all times, whether in the air or on the ground, whether at the gate or taxiing, the pilot-in-command (PIC) has final and ultimate responsibility for the safe operation of the aircraft. Per ICAO Annex 2 (with similar statements/definitions by individual civil authorities):


  The pilot-in-command of an aircraft shall, whether manipulating the controls or not, be responsible for the operation of the aircraft in accordance with the rules of the air, except that the pilot-in-command may depart from these rules in circumstances that render such departure absolutely necessary in the interests of safety.


As you stated, the pilot is allowed to deviate from any ATC instruction or regulation to the extent necessary to ensure the safety of the crew, passengers and property. If necessary, the PIC may enlist additional resources, such as a ground crew, to deal with issues like not being able to see behind the airplane. For airline operations, this is usually spelled out by the airline's operations procedures, which the PIC effectively "approves" (as the ultimate authority for the aircraft's operation) and carries out. 

Air traffic controllers have what you might call "jurisdiction" over certain parcels of airspace and airports. The gates and the area immediately surrounding them are usually not under the jurisdiction of the control tower. They are instead managed by the airport authority. At large airports, the airport may operate a "ramp control" system with its own (smaller) control tower and radio frequencies. Arriving and departing aircraft coordinate with ramp control to get into and out of the gates safely. Ground crews will assist the pilot-in-command with parking and pushback operations, getting the aircraft to a point where the PIC can taxi the aircraft to leave the ramp area and enter the taxiway system in accordance with ATC taxi instructions.

Once on the taxiways, and from there to the runway and into the air, the aircraft is under the jurisdiction of the regular air traffic controllers. The controllers can divide up this area between different positions, usually a "ground controller," a "tower" or "local controller," and one or more approach/departure radar controllers.