The pact, which has been in the works for more than a year, is part of efforts led by Germany and France to push closer defense ties as a way of rebooting the bloc after Britain's referendum to leave.
Defense and foreign ministers from the 23 countries signed a notification of their intention to establish the Permanent Structured Cooperation (PESCO), which allows countries to cooperate more closely on security operations and building up military capability.
"It's going to be quite a historic day for European defense", EU foreign policy chief Federica Mogherini told reporters before the meeting in Brussels at which ministers approved the plan.
Apart from Britain, Denmark, Portugal, Ireland and Malta have yet to decide whether to join the pact.
Trump has criticized other North Atlantic Treaty Organisation members that fail to meet the North Atlantic Treaty Organisation defense spending target of 2 per cent of gross domestic product.
"I'm a firm believer of stronger European defense, so I welcome PESCO because I believe that it can strengthen European defense, which is good for Europe but also good for NATO", Stoltenberg said.
In all just five member nations failed to sign up to the process, known as permanent structured cooperation, or PESCO. Germany wanted the pact to include as many countries as possible while France wanted it to be as militarily ambitious as possible, they said.
U.S. President Donald Trump refused last month to certify that Iran is complying with its obligations under the nuclear accord, though global inspectors said it is.
The agreement envisions a Permanent Structured Cooperation, or PESCO, which is meant to give the European Union a more coherent role in tackling global crises, follows the announcement of a $6.4-billion European Defense Fund last June.
Participants have signed up to a list of commitments which "include increasing the share of expenditure allocated to defense research and technology with a view to nearing the 2 percent of total defense spending" and to "regularly increasing defense budgets in real terms".
PESCO is meant to lead to deeper military cooperation within the European Union, project financing, development of military technology and strengthening of the EU's defense industry.