The UK is to increase its military support to Nigeria to help protect its citizens and British workers in the country from terror attacks.
The Nigerian armed forces will be given specialist equipment and training to counter the use of improvised explosive devices by Islamist insurgents.
On a visit to Abuja, Theresa May said tackling the "menace" from groups like Boko Haram was in the UK's interest.
She has also agreed a £10.5m package to help victims of modern slavery.
As part of this, the UK will provide counselling to up to 1,700 people who have been subjected to forced labour, domestic servitude and sexual abuse and help them re-integrate into their communities.
A joint initiative with France will also see the UK assist Nigeria and Niger strengthen their border cooperation to prevent trafficking of migrants to Libya and Europe.
After talks with President Muhammadu Buhari in the nation's capital Abuja, Mrs May announced the two countries had signed a defence and security partnership which could see the UK train, for the first time, full army units to combat insurgents in the north-east of Nigeria.
The UK, which has trained 30,000 Nigerian troops since 2015, will also help set up an emergency response mechanism, along the lines of the UK's Cobra crisis system, to deal with terror attacks while also stepping up efforts to tackle the propaganda spread by Islamic State-Daesh and other militant groups.
"We are determined to work side by side with Nigeria to help them fight terrorism, reduce conflict and lay the foundations for the future stability and prosperity that will benefit us all," Mrs May said.
The PM also announced further co-operation on piracy, organised crime and human trafficking, including a new taskforce to help Nigeria recover stolen assets held in the UK.
Labour's Shadow Home Secretary Diane Abbott said Mrs May's "warm words" rang hollow as her government had cut Border Force staff and police officers, who were "the frontline in the fight against modern slavery".
Mrs May's three-day trip to Africa, which began in South Africa on Tuesday, is aimed at deepen economic and trade ties with growing African economies ahead of Britain leaving the EU in 2019.
Mrs May said Brexit would increase opportunities to extend existing commercial links with Nigeria - the UK's second largest trading partner in Africa - particularly in the area of financial services.
"We offer, as the United Kingdom the important capacity the bring in the access to capital markets through the City of London together with professional service expertise with great private sector companies," she said.
She has already announced £4bn of extra British support for African economies and said she wanted the UK to overtake the US to become the G7's biggest investor in Africa by 2022.