As always when a new firmware is being realeased, there is always a few unlucky people who "accidentally" update or restore to the latest firmware, thus losing their jailbreak and unlock.
In this case, you'd usually want to downgrade your iPhone from 3.1.3 to 3.1.2 simply by downloading 3.1.2 and SHIFT + Restore in iTunes so that you can choose your own firmware to restore to.
The problem is that Apple recently stopped signing all previous firmware versions making it impossible for you to downgrade.
Fortunately, Saurik has been smart enough to create a system to bypass Apple's signature and making it possible for you to downgrade from 3.1.3 to 3.1.2. To do so, you will need to have your SHSH on file. To see if it's on file, launch Cydia and look at the top. Mine says "This device has SHSHs on file for iPhone OS: 3.0, 3.1, 3.1.2".
If you don't have this, make sure you look for a link that says "Make my life easier" on Cydia. This will allow you to save your SHSHs.
This being said, downgrading an iPhone 3GS from 3.1.3 to 3.1.2 is easier said than done. It's actually a pretty painful process that I detailed in a tutorial a few month ago. I originally wrote this tutorial to downgrade from iPhone 3.1 to 3.0 but the steps are exactly identical (MuscleNerd confirmed this).
If you're one of those who need to downgrade your iPhone firmware, then check out my tutorial, or simply wait for the Dev Team to come up with a reliable jailbreak for 3.1.3. Something tells me PwnageTool is not too far ahead of us ;)
UPDATE: If you have an iPhone 3G, you can now downgrade from baseband 05.12.01 to o4.26.08.
UPDATE 2: This post is slightly outdated. Check out this page for the latest information about downgrading your iPhone.