This is a question scholars have worked through carefully in the modern era, weighing the sanctity of the human body against the Quran's powerful principle that 'whoever saves a life, it is as if he had saved all of mankind' (5:32). Most contemporary fiqh councils and scholars have concluded that organ donation is permissible, and can even be a great act of ongoing charity, under certain conditions: the donation genuinely saves or significantly improves another life, it is not bought or sold, the donor consented during life (or the family consents on their behalf), and the removal is done respectfully, without unnecessary mutilation. Some scholars remain more cautious, especially regarding donation from a living donor if it involves real risk to them, or object on the grounds of the body's inviolability even after death. Because rulings can differ by school and by the specific circumstance, it's worth asking a knowledgeable local scholar or fiqh council, but there is solid ground within the tradition for it being a permissible, even praiseworthy, choice.
Q&A · Death & Afterlife
Is organ or body donation after death permissible?
References
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.