How should I rewire a miswired 3-way switch?
I had this EXACT issue when I moved into my new (to me) house. The original owner was a bit of a handyman and had done several small (and big) projects all over. In many cases regarding electrical work he'd done, I had to go back in and clean up.

Here's a fail-safe process to fix a three way setup that isn't working:


Turn off the breaker controlling this light. You may also need to cut additional breakers if either or both of the 3-ways are in "multi-gang" boxes with other switches on different circuits. Use a non-contact voltage tester to ensure all of the screws on the side of all the switches in both boxes are dead before pulling out any switches.
Disconnect all wires from both of the 3-way switches (but do not unwrap or un-nut any of the twisted wire bundles, or disassemble any other switches). Pull these wires out of the box and separate them so there is no bare copper touching any other metal.
Turn the panel breaker back on. From this moment until step 5, the second you are not extremely cautious around every bit of bare metal in that box, you will pay for it.
Probe all the wires you disconnected and separated one at a time with your non-contact voltage tester, being extremely careful not to touch any of the other wires with the tester or any part of you. You will find one loose black wire in one of the two boxes that is live, and all other wires should be dead. The live wire is your panel hot; remember it.
Turn off the breaker at the panel again.
Back at the box with the wire you identified as the panel hot, connect the hot wire to the "common" terminal of the 3-way switch for that box. Looking at the body of a three-way switch, the common terminal is the terminal that has another terminal screw on the switch body facing the same way, but doesn't have a screw directly across the switch body facing the other way. A picture's worth a thousand words; see below.
The other two insulated wires you removed from the switch are the "traveler" wires. One will be black, and the other red, and they should both be a part of the same "trunk" of Romex wire. Connect the black to one of the remaining terminals other than the grounding terminal, and the red to the other terminal.
Both of the two wire "trunks" should have white and bare wires in addition to the black and/or red; ALL the white wires in the box should be twisted into a bundle with a wire nut, and all bares should be twisted in a bundle with or without a nut.
Screw the terminals down firmly, attach the ground wire to the green grounding terminal screw if one was connected (bathrooms require a bare wire ground to be connected to the switch, most other rooms don't), cover all the switch terminals with a layer or two of electrical tape, and, being careful not to short out any wires, push the wires and switch back into the J-box and screw it down.





Now, go to the other switch box. Examine the loose wires which you disconnected from the switch (there should be two black and one red). The black wire that doesn't go into the same outer insulation conduit as the red wire is the hot lead to the light. The other two wires are the other ends of your traveler line. Both these "trunks" should have white and bare wires in addition to the black and/or red; the white wires should be twisted into a bundle with a wire nut, and bares should be twisted in a bundle with or without a nut.
Connect the light's hot wire to the switch's common terminal.
One note; if you connect the black wire from the traveler to the same side of the second switch that you connected the black traveler wire to on the first switch, the switches must be set opposite each other (one up and one down) for the light to be off. Personally, I prefer to be able to turn every light in the house off by pushing all the light switches down. If you're like me, then swap the red and black wires of the traveler pair, connecting the black wire to the opposite traveler terminal from the one you used on the first switch. This will result in the circuit being off when the switches are set the same way (both down or up).
Connect the traveler wires to the other switch terminals in the manner you choose, and connect the ground if you have one. Wrap the terminals in electrical tape, and put the switch back in the wall box.
Turn the panel breaker(s) back on. Have another person stand at one switch, while you stand at the other. If the light is on, flip one of the switches. Now, have the other person flip their switch; the light goes on. Flip yours (light off). Flip theirs again (light on), then flip yours again (light off). You've now gone through all four combinations of light positions, and verified that either switch can turn the light on or off.
If something still doesn't work, turn off the panel and take the switches out of the box (but don't disconnect them). Make sure none of the terminals are shorting out against any other piece of metal in the box (including the box itself, if it's conductive). If it STILL doesn't work, replace one or both switches (they're about $3 a pop). if it STILL doesn't work, I'd call an electrician; there may be a break in the wires of this circuit, or there may have been a mix-up involving multiple switches in the boxes; pretty much any way you slice it it could be dangerous or expensive for you to continue to try to fix it.
Once the switches are working to your satisfaction, put the switch plate back on over the box (make sure before you start screwing in plate screws that ALL the holes line up), and enjoy your repaired three-way circuit.