Transplant rejection occurs when the recipient's immune system recognizes the transplanted organ as foreign and attempts to attack it.