Speaking at the FBI meeting on Wednesday, Wray said: "I've decided the right thing for the bureau is for me to serve until the end of the current administration in January and then step down."
"In my view, this is the best way to avoid dragging the bureau deeper into the fray, while reinforcing the values and principles that are so important to how we do our work," Wray added.
He received a standing ovation after his remarks, with some in the audience crying, an unnamed official told the Associated Press.
Trump appointed Wray to lead the FBI after firing his predecessor James Comey following the FBI's investigations into alleged contacts between the 2016 Trump campaign and Russia.
When appointing him, Trump said Wray - a Yale Law School graduate - was a man of "impeccable credentials".
But in recent years, Wray has fallen out of favour with the president-elect after the FBI assisted with a federal probe into Trump's handling of classified documents, a case that has since been dropped.
Trump said Wray's resignation was "a great day for America".
"It will end the Weaponization of what has become known as the United States Department of Injustice," he said on Truth Social. "We will now restore the rule of law for all Americans."
Following his election to a second term, Trump said his pick for FBI director would be Patel - a former aide who has been a steadfast supporter of the incoming Republican president.