The pact came after hours of negotiations ahead of the military organization’s summit in Lithuania.