The classical formulation is Bagehot's: lend freely, at a high rate, against good security. The high rate is what keeps the facility from being used casually; the good collateral is what protects the central bank from taking credit losses.
The mechanism is the discount-window plus, in crises, purpose-built facilities against specific collateral. The practical problem is stigma: banks avoid borrowing because using the window is read as a distress signal, which blunts the tool exactly when it is needed.
Example: a bank facing deposit outflows pledges $10 billion of Treasuries and borrows at the primary credit rate of 4.50% while the target-range top is 4.50%. It pays a small premium over market funding and avoids selling assets into a falling market.
Related: discount-window, standing-repo-facility, federal-reserve, collateral, haircut