To reach an agreement, deal, or solution through difficult negotiation or sustained effort.
"After two days of intense talks, the two sides finally hammered out a peace agreement."
The two sides hammered out a compromise that neither loved but both could live with.
— Widely used formulation in political journalism; e.g. The New York Times, various issues covering US Congressional negotiations