...you don't tweet something inappropriate about them or the situation until you've had time to investigate what happened. Avoid going into details at this point.
Saying something along the lines of "Please note: Unsanctioned account activity - previous tweets sent in error - normal service will resume soon" should do the trick. While it sounds a little robotic, you do need to take care about publishing an apology.
Dangers of publishing an apology
Sorry might be the instinctual - and human - thing to say but it depends on the content of the inappropriate tweets.
If they were potentially libellous, you should consult with the company lawyer on the best course of action. If you publish an apology you are publicly acknowledging culpability so you need to ensure this is the appropriate course of action.
Of course if the tweets were inappropriate in a more general sense - that is, not specifically targeting an individual or company but just a bit crude - then saying sorry and sounding human when doing so is likely to be the best plan.
Once you've had a chance to find out exactly what went wrong then you can make your next tweet count: something along the lines of "Really sorry for the previous tweets - our account got hacked", or "Mortified by the previous tweets - now deleted - sent in error. Very sorry all".
Next you should assume everyone has seen the offending tweets and be checking your @mentions to see whether any of your followers are specifically asking about or commenting on them.
It's also worth monitoring a few relevant keywords - and any resulting hashtags that have been created at your expense - so you can get a sense of how much chatter is being generated, what people are saying and how to shape your response.
Third-party Twitter clients such as Seesmic and TweetDeck have options to set up keyword searches, which can make this process more manageable.
Reply to each @mention individually if possible but if you have too many followers trying to engage you to tackle every one then regularly post tweets that acknowledge the volume of @mentions you are getting and reiterating your apology.
Remember your sense of humour
Don't start spamming your followers by posting a new "We're really sorry" tweet every second - that just looks panicky. Instead post regular updates - commensurate with the number of @mentions and any wider Twitter chatter about the blunder - roughly no more than once per half hour.
If the chatter is generally humorous then you can relax a bit and if you're confident that your marketing department is now able to see the funny side of things, then a bit of self-depreciating humour could be in order, as a way of further defusing the situation.
Any negative passing comment from Twitter users should be treated courteously - that's if you do decide to engage directly with it. But if it's really vitriolic then it's probably better ignored since it's not being directly sent to you, otherwise you risk drawing unnecessary attention to it - without which it will soon fade away into the general Twitter babble.
Finally there's the old axiom to consider: "There's no such thing as bad publicity", which is simply not true. There are of course dire PR moments - Gordon Brown's comment about that "bigoted woman", say. But what is true is that bad publicity is exacerbated by clumsy handling of a situation. Your tweet may have been hideous but deal with it in the right way and you could still come away looking good.
Above all, show yourself to be calm and efficient under pressure, courteous to those you have offended, and apologetic where appropriate. Then, once the immediate furore has died down, dust off your sense of humour. When it comes to disarming your critics, it may well be the best weapon you have.
Have you had to clean up after a Twitter blunder? Let us know how you dealt with it by posting a Reader Comment below...