The city has agreed to pay two Occupy Wall Street protesters $52,000 after they were arrested for flipping the bird to officers on the subway, unprovoked.

Channing Creager, 26, of Brooklyn, and her pal Nicholas Thommen, 33, of Detroit, were on the E train in June 2013 when they saw uniformed officers ­Diane Bowman and John Patrick Harrigan in their car, according to their suit.

“Thommen and Creager gestured toward Bowman and Harrigan with their middle finger raised, an internationally recognized symbol of dislike and displeasure, and in doing so exercised their constitutional right, guaranteed under the state and federal constitutions, to freely express themselves,” the suit states.

The officers exited the car with the pair at the next stop in Queens and asked for identification before cuffing them and taking them to the 110th Precinct station house, court papers say.

Creager and Thommen were charged with disorderly conduct and spent the night in jail.

The Occupy Wall Street participants asserted that cops falsely claimed that they shouted ­obscenities and insults at them during the confrontation.

The cops said Thommen screamed, “All cops are rapists!” and Creager yelled “f–k these cops, man!” the suit states.

Charges against the pair were later dropped in Queens Supreme Court and Creager and Thommen sued for civil-rights violations in Brooklyn federal court.

They asserted that their right to be gratuitously profane was protected by the Constitution.

The city agreed to settle the case for $52,000, to be split evenly between two.

“Our clients are satisfied and relieved that the city has acknowledged their constitutional right to express themselves even when those expressions may be considered offensive, controversial or unpopular,” said their attorneys, Edward Donlon and Jason Leventhal, in a statement.

A city Law Department spokesman said, “The settlement was in the best interest of the city.”