WASHINGTON—President Trump ordered the removal of the ambassador to Ukraine after months of complaints from allies outside the administration, including his personal lawyer Rudy Giuliani, that she was undermining him abroad and obstructing efforts to persuade Kyiv to investigate former Vice President Joe Biden, according to people familiar with the matter.

The recall of Marie Yovanovitch in the spring has become a key point of interest in the House impeachment inquiry. A whistleblower complaint by a CIA officer alleges the president solicited foreign interference in the 2020 elections by pressing Ukraine’s president in a July 25 call to pursue investigations, including into the activities of Mr. Biden, a Democrat who is running for president.

The complaint cites Ms. Yovanovitch’s ouster as one of a series of events that paved the way for what the whistleblower alleges was an abuse of power by the president. Mr. Trump has described the call with his Ukrainian counterpart as “perfect” and the House inquiry as a “hoax.”

State Department officials were told this spring that Ms. Yovanovitch’s removal was a priority for the president, a person familiar with the matter said. Secretary of State Mike Pompeo supported the move, an administration official said. Ms. Yovanovitch was told by State Department officials that they couldn’t shield her from attacks by the president and his allies, according to people close to her.

In an interview, Mr. Giuliani told The Wall Street Journal that in the lead-up to Ms. Yovanovitch’s removal, he reminded the president of complaints percolating among Trump supporters that she had displayed an anti-Trump bias in private conversations. In Mr. Giuliani’s view, she also had been an obstacle to efforts to push Ukraine to investigate Mr. Biden and his son Hunter.