WASHINGTON- Barclays has agreed to pay $2 billion for allegedly causing billions of dollars of losses to investors by engaging in a fraudulent scheme to sell residential mortgage-backed securities between 2005 and 2007, the U.S. Justice Department said on Thursday.

The department said the firm misled investors about the quality of the mortgage loans backing those deals and committed violations of mail fraud and bank fraud. According to the Justice Department's statement, Barclays disputes the allegations.

The settlement resolves the British bank's largest outstanding legal issue in the United States, and could offer reassurance to investors who had been braced for a potentially larger fine.

"I am pleased that we have been able to reach a fair and proportionate settlement with the Department of Justice. It has been a priority for this management team from the start to resolve these historic issues in a timely and appropriate manner wherever possible," Barclays Chief Executive Jes Staley said.

Barclays shares were trading 0.7 percent up at 1332 GMT following news of the settlement.

Barclays said paying the fine would hit its core capital ratio, a key measure of financial strength, by 0.45 percentage points.

Two former Barclays executives, Paul Menefee and John Carroll, who worked on the RMBS deals paid a combined $2 million in exchange for claims against them being dismissed, the Justice Department said.

(Editing by Eric Beech and Sinead Cruise) ((M.Brice@thomsonreuters.com; +1-202-310-5675; +1-202-558-8211;))