BANGOR, Maine — A federal judge on Tuesday ruled in favor of Gov. Paul LePage and dismissed a lawsuit filed by House Speaker Mark Eves over his loss of a job at Good Will-Hinckley.

U.S. District Judge George Singal issued a 44-page ruling that found LePage was immune from the lawsuit.

David Webbert, Eves’ attorney, said the decision would be appealed to the 1st U.S. Circuit Court of Appeals in Boston.

“We are confident that the court of appeals will agree that Gov. LePage violated the basic rules of our Constitution when he used taxpayer money to blackmail a private organization into firing his political opponent for partisan purposes,” Webbert said in a statement. “Mark Eves is determined to hold Gov. LePage accountable for his abuses of power that undermine our democracy.”

Patrick Strawbridge, the Boston attorney representing LePage in the lawsuit, also issued a statement.

“The governor is pleased with the result, and appreciates the careful attention and decision of the court,” he said. “We remain confident that this case is without merit and will continue to defend it vigorously should the speaker decide to appeal.”

Eves, a Democrat, sued LePage, a Republican, on July 30, 2015, in U.S. District Court in Bangor alleging the governor illegally retaliated against Eves over their political differences by threatening to withhold state funding from his future employer, Good Will-Hinckley.

Eves and the nonprofit organization, which includes the Maine Academy of Natural Sciences charter school in Fairfield, signed an employment contract in late May 2015. He was to have begun working as its next president on July 1, 2015.

The school rescinded its offer to Eves of North Berwick in June 2015. Eves has publicly accused LePage of pressuring the school to do so by vowing to withhold $1.06 million in state funding over the next two years.

Attorneys for the governor filed a motion to dismiss on Jan. 5. Singal heard oral arguments on that motion in Portland on April 13.

“Quite simply, the discretion afforded the governor is significantly greater than the discretion afforded to a police officer,” Singal wrote. “In the court’s assessment, the scope of the governor’s discretion clearly encompasses advocating for his preferred charter school policy and ensuring that enacted legislation involving charter schools is followed.

“Moreover, it is explicitly clear that the governor retained discretion to expend and disburse funds for a school that was designated as ‘the Center of Excellence for At-risk Students’ [outlined],” he said.

“Ultimately, the governor’s alleged threats were made in his official capacity, and the individuals hearing those threats believed that the governor could exercise his executive discretion to impound amounts appropriated in the budget,” Singal concluded. “Therefore, even assuming his threats to withhold such funds from GWH amounted to an abuse of his discretion, the court finds that the Governor is entitled to immunity under [the law].”

Earlier this year LePage successfully fended off an impeachment effort in the Maine House of Representatives, according to previously published reports. The impeachment order called for the creation of a 13-member committee to investigate eight alleged acts of misconduct by LePage, ranging from his blocking his commissioners from speaking to legislative committees to his role in forcing Good Will-Hinckley to fire Eves.

After more than three hours of debate, the measure failed with a 96-52 vote.

Eves did not participate in the debate. LePage castigated lawmakers for “wasting time” and vowed to work to defeat those who supported impeachment.

Singal mildly scolded Eves and LePage for moving their political differences from the State House to the federal courthouse.

“The factual allegations laid out [in the case] clearly display a ‘war of words’ between the head of Maine’s executive branch and a leader of Maine’s legislative branch,” the judge wrote. “Such battles are an inevitable and intended part of a government built on the separation of powers. As the First Circuit explained in another recent case, ‘Governors and administrations [as well as legislators] are ultimately accountable to the electorate through the political process, which is the mechanism to test disagreements.’

“As the extensive analysis that follows shows, the federal courts serve as a poor substitute mechanism for resolving such disagreements,” Singal said. “In fact, many of the doctrines discussed [in this ruling] were developed to avoid the use of the judicial branch to resolve political disputes that are rightly reserved for the electorate.”