To deflect an enemy attack simply tap the Guard button (L1/LB) as an attack is coming; this negates all damage from most attacks, builds up the enemies Posture gauge by a significant amount, and staggers most enemies briefly, allowing you a small window to counter attack. This posture damage per Deflection is increased if the player manages to Deflect multiple attacks in a short period of time, such as an attack flurry.
The time window to deflect enemy attacks is actually a generous 30 frames by default (a full half second before the attack hits), though this window can shrink if the user has recently released the Guard button (with each recent press shrinking the window further, to as little as 7 frames); as such, spamming the button in hopes of a successful deflect is not recommended. Fortunately, the stacking penalty is removed after a period of time (30 frames) as well as immediately following a successful Deflect... and in fact, spamming Deflect is actually necessary if an enemy performs a rapid attack flurry with multiple consecutive attacks. Similarly, holding the guard button down and releasing immediately before pressing it again to Deflect also accrues this penalty and makes it much more difficult to Deflect. Instead, one can guarantee a successful defense by pressing down the Guard button earlier rather than later: if properly timed, the Deflection attempt works, while if too early, the user will simply Guard the attack instead.
Enemies can also deflect your attacks, but this will not deal any Posture damage; you will generally recover slower than your opponent after your attack is deflected, however, making follow-up attacks risky or impossible.
Some enemy attacks, called Perilous Attacks, are dangerous or impossible to Deflect, you have to deal with them in certain ways; a red Kanji meaning "danger" will appear to indicate Perilous Attacks. Other attacks will deal damage to Sekiro whether he deflects or guards them: attacks which inflict the terror or fire status effect will almost always deal a portion of their damage through Sekiro's guards and deflects, though a weapon blessed with Divine Confetti can Deflect terror attacks from apparitions. Unfortunately, the negative status effect buildup of Poison, Fire, and Terror cannot be blocked using a traditional guard or deflect, instead requiring the use of the Umbrella Shield.