First, it helps to understand that the Pearl Harbor anchorage is fairly shallow. The battleships weren't completely underwater. Their superstructures and main gun turrets were still visible, and in some cases, the upper deck was out of water. This was one of the flaws of the Pearl Harbor attack... had the ships been attacked in open water, they would have been completely lost in deep water.
The US Navy documented the salvage on this site. Here's a quick summary:
USS Nevada was the first to be salvaged, as it didn't actually sink. Nevada was able to get under way during the attack, and was run aground when flooding from a torpedo hit threatened to sink it. Divers plugged the one torpedo hole and several bomb holes, water pumped out, and Nevada was refloated with a month. In the process, several people died from high concentrations of hydrogen sulfide gas that had accumulated in the hull, leading to stringent anti-gas measures being taken for the rest of the salvage effort.
USS California had a lot more holes in it, requiring a cofferdam to be built around portions of the hull to get the damaged area above water for repair. Some of the superstructure and the main gun turrets were removed to lighten the ship. California, along with West Virginia, were returned to service by 1944.
Less damaged were USS Pennsylvania, Maryland, and Tennessee, as they were on the inside row (the battleships being docked in two rows) and thus not subject to torpedo attack, only bomb attack. They were refitted, upgraded and returned to service by 1943.
USS Oklahoma and USS Utah had capsized, rolled over, due to one side of the ship being flooded from torpedo hits. They were righted by parbuckling, a procedure used to right the Costa Concordia during its salvage, where cables are attached to platforms built on the hull and then the hull was rolled back upright. These two ships, along with USS Arizona, were too badly damaged to be returned to service, and all three remain in Pearl Harbor today. Their guns were removed and transferred to harbor defense or new construction. Their salvage was more to remove the bodies trapped in the hull than anything, except for Arizona, whose casualties remain in the hull to this day.
Overall, the salvage of the Pearl Harbor battleships was one of the more impressive engineering feats of the war. This was as much national pride as anything - by the time the last battleship had been refloated, both sides in the war recognized that the aircraft carrier was now the most prominent naval weapon in the war.
Unless the aircraft carriers are sent in the wrong direction...
In a twist of irony, salvaged Pearl Harbor battleships California, Tennessee, Maryland, Pennsylvania, and West Virginia spearheaded the last battleship on battleship action in history. They were attached to Admiral Jesse Oldendorf's Seventh Fleet when it met Admiral Nishimura's Southern Force in the Battle of Surigao Strait, 25 October 1944, as part of the Leyte Gulf action. Nishimura's fleet was roundly defeated by the 'ghost ships' of Pearl Harbor, with both of his battleships being sunk.
This action played out as pure ship on ship as Halsey had sent all of his carriers after Ozawa's decoy carriers... which had almost no aircraft or pilots.