Mr McGahn can continue to challenge the ruling and is unlikely to have to testify anytime soon. It is unlikely he will testify prior to the 2020 US election.
However, congressional Democrats view the ruling as a win, as it confirms that they can win in federal courts that have been packed by judges appointed by Mr Trump.
Two Trump-appointed judges sitting on the appeals court – Neomi Rao and Greg Katsas – recused themselves from the case. The court's final ruling was 7-2.
The Court of Appeals for the District of Columbia Circuit ruled that Mr McGahn's refusal to testify is grounds for the House to bring him to court.
In the trial-court ruling of the McGahn case, the judge included in her opinion the phrase: "Presidents are not kings."
The House Judiciary Committee has sought testimony from Mr McGahn since 2019. Democrats on the committee want to question him about the Mueller Investigation and possible obstructive actions Mr Trump took to derail the probe.
Jerry Nadler, the House Judiciary Committee Chairman, said the ruling undermined the "wall of impunity that President Trump has tried to build for himself".
"And it reaffirms the core principle behind the Supreme Court's ruling last month: No one – not even the President – is above the law," Mr Nadler said.
The US Justice Department – which is representing Mr Trump and his administration – opposed the appeals court's ruling. It argued that courts should stay out of battles that can be considered largely political and allow lawmakers and legislation to compel actions from the Trump administration.
"While we strongly disagree with the standing ruling in McGahn, the en banc court properly recognised that we have additional threshold grounds for dismissal of both cases, and we intend to vigorously press those arguments before the panels hearing those cases," Justice Department spokeswoman Kerri Kupec told CNN.
The dissenting judges in the case – Judges Karen LeCraft Henderson and Thomas Griffith – argued that the ruling will only lead to more lawsuits in the future, and predicted that political parties will rush to litigation when they are in dispute rather than settling disagreements through politics.
"The majority's ruling will supplant negotiation with litigation, making it harder for Congress to secure the information it needs," Judge Griffith wrote.