Washington and Madrid signed a deal Wednesday setting up a permanent force of 2,200 US Marines based in southern Spain who can be swiftly deployed to crises in Africa.
The US already has a rapid reaction force of about 800 troops at Moron de la Frontera, near Seville, who were deployed temporarily in the wake of the 2012 attack on a US mission in Benghazi, eastern Libya.
Four Americans, including the ambassador Chris Stevens, were killed when dozens of armed militants stormed the compound and a nearby CIA facility in an hours-long gunbattle, which triggered protests that no US troops could be deployed fast enough to help them.
"The deployment at the Moron base will be made permanent with a force of 2,200 military personnel and 500 civilian staff plus 26 aircraft," Spain's Deputy Prime Minister Soraya Saenz de Santamaria said late last month.
Top US diplomat John Kerry had been due to sign the deal on his first trip to the country as secretary of state in May.
But he fell while cycling in the Alps and had to be flown home to Boston for surgery to a broken right leg, forcing him to cancel the visit.
Wednesday's accord, which amends a 1988 defense partnership between the two countries, was signed instead by Deputy Secretary of State Tony Blinken and Spanish Deputy Foreign Minister Ignacio Ibanez.
The main mission of the Special-Purpose Marine Air-Ground Task Force Crisis Response unit will be to protect US embassies in Africa, evacuate civilians in difficulty, or intervene in conflicts or humanitarian crises.
It will come under the US military command for Africa (AFRICOM) which is based in Stuttgart, Germany.
Blinken said Washington was very "grateful to our Spanish allies and friends for this agreement," which showed that the partnership between the two countries "every day grows stronger."
Ibanez welcomed the signing, saying it was a "very important agreement."
Blinken also handed a letter to Ibanez from Kerry, saying the secretary of state had wanted to attend in person, but was still recovering from his injury.