A robust obstacle detection and avoidance system is essential for long term autonomy of autonomous underwater vehicles (AUVs). Forward looking sonars are usually used to detect and localize obstacles. However, high amounts of background noise and clutter present in underwater environments makes it difficult to detect obstacles reliably. Moreover, lack of GPS signals in underwater environments leads to poor localization of the AUV. This translates to uncertainty in the position of the obstacle relative to a global frame of reference. We propose an obstacle detection and avoidance algorithm for AUVs which differs from existing techniques in two aspects. First, we use a local occupancy grid that is attached to the body frame of the AUV, and not to the global frame in order to localize the obstacle accurately with respect to the AUV alone. Second, our technique adopts a probabilistic framework which makes use of probabilities of detection and false alarm to deal with the high amounts of noise and clutter present in the sonar data. This local probabilistic occupancy grid is used to extract potential obstacles which are then sent to the command and control (C2) system of the AUV. The C2 system checks for possible collision and carries out an evasive maneuver accordingly. Experiments are carried out to show the viability of the proposed algorithm.