Under pressure over impeachment, his Syria policy and other issues, the president tweeted: "So some day, if a Democrat becomes President and the Republicans win the House, even by a tiny margin, they can impeach the President, without due process or fairness or any legal rights.
"All Republicans must remember what they are witnessing here - a lynching. But we will WIN!"
Lynchings, or hangings, were historically mostly used by whites against black men in the South beginning in the late 19th century amid rising racial tensions in the US.
By comparing the impeachment process to a lynching, Mr Trump is also likening Democrats to a lynch mob.
The highest-ranking African American in Congress warned the president about the comparison.
House majority whip Jim Clyburn said: "That is one word no president ought to apply to himself. That is a word that we ought to be very, very careful about using."
Another black Democratic representative, Bobby Rush, called on Mr Trump to delete the tweet.
"Do you know how many people who look like me have been lynched, since the inception of this country, by people who look like you. Delete this tweet," wrote Mr Rush.
But Republican senator Lindsey Graham agreed with Mr Trump, telling reporters the president's description was "pretty well accurate", adding that the impeachment effort is a "sham" and a "joke" because the president does not know the identity of his accuser and the process is playing out in private.
Mr Graham told reporters on Capitol Hill: "This is a lynching in every sense. This is un-American."
Mr Trump has a habit of trying to portray himself as the victim.
His tweet came a day after he lashed at critics of his decision - since rescinded - to schedule a major international economic summit next year at one of his Florida golf resorts.
He complained on Monday about "you people with this phoney emoluments clause".
The emoluments clause in the constitution bans presidents from receiving gifts or payments from foreign governments.
A whistleblower's complaint that Mr Trump was attempting to use his office for personal political gain during a July 25 phone conversation with Ukraine's president led House speaker
Nancy Pelosi to open the impeachment inquiry.
The president insists he did nothing wrong, characterising the conversation with Volodymyr Zelenskiy as "perfect" and arguing that Democrats are still trying to overturn the 2016 election that put him in the White House.