In general, IRAs are designed to be one-way streets. You pay in while you're working and you withdraw in retirement and never the two shall meet. These rules are in place to prevent abuse of the IRA's tax-protected status, and there are penalties if you break them. There are a few exceptions, however, including the 60-day redeposit rule -- a helpful option if you need cash for a very short period of time.
The 60-day Rule
If you withdraw money from your IRA and redeposit the same amount within 60 days, it effectively doesn't count. You will not be charged a penalty for early withdrawal, and you do not need to pay taxes on the withdrawal. The reverse is also true -- you do not get a tax deduction for the re-deposit in a traditional IRA. The 60-day rule is applicable to both Roth and traditional IRAs.
In most cases, you can redeposit your IRA withdrawal in the same way you make a contribution each year -- via check or direct deposit to your IRA provider. Since deposits and withdrawals do have tax consequences, it's best to check in with your IRA custodian and tell them what you're doing. This ensures that your end-of-year tax forms reflect your actual activity, not someone's best guess.
Taxes and Penalties
Most IRA custodians withhold tax and penalties from IRA withdrawals automatically. You can opt out of this -- simply inform your IRA provider that you do not want any tax or penalties withheld. If you do have tax or penalties withheld, be aware that you will need to make up the difference when you complete your redeposit: if you have $100 withheld from a $1,000 withdrawal, you have to redeposit $1,000 to qualify for the 60-day rule, not $900. You don't lose the $100, though -- it gets counted as part of your total tax paid and will decrease your tax payment or increase your refund accordingly.
You do not have to redeposit your IRA money to the exact same account you removed it from. As long as the money goes into the same type of account -- traditional or Roth -- you can deposit it to any account you own, or even a completely new one.
Roth Principal Exceptions
If you have a Roth IRA and it has been open for more than five years, you can withdraw the value of your contributions -- not earnings -- from your account at any time without replacing it and you will not be penalized. The same is true for all traditional-to-Roth conversion money that is at least five years old.
Remember that any money still withdrawn after 60 days is a withdrawal and subject to tax and penalties. See IRS Publication 590 for applicable tax and penalties in your situation.