It has long been known that the iPhone Dev Team unlock Ultrasn0w-who recently came out for the iPhone 3G and so would work on iPhone 3GS. The only thing missing was a way just a jailbreak of 3GS. iPhone Dev Team announced recently that they had a jailbreak clear, but they would not release it until iPhone OS 3.1 was released.
Another iPhone hacker, GeoHut as anyone might remember from the "old days", does not share the dev team's position to keep a secret jailbreak.
He has created a program that can jailbreak iPhone 3GS (runs on Mac or Windows). With barely disguised allusion to the dev team ultrasn0w, yellowsn0w and Redsn0w he calls his program purplera1n. You can find programs here: purplera1n.com