Media playback is unsupported on your device Media caption President Obama covered a wide range of issues in his interview with the BBC's Jon Sopel

Barack Obama spoke with the BBC ahead of his trip to East Africa. Here is the full transcript of North America Editor Jon Sopel's conversation with the US president.

Going to Kenya

JON SOPEL: Mr President, you're about to fly to Kenya, to your ancestral home. Given the al-Shabaab attacks on the West Gate mall and Garissa University, I'm sure your secret service could've suggested other countries for you to visit. But you wanted to go to Kenya.

PRESIDENT BARACK OBAMA: Well, I think it is important first of all that the president of the United States underscores our commitment to partnering with countries around the world, even though we're not intimidated by terrorist organisations. Second, the counterterrorism co-operation between the United States and Kenya - and Uganda and other countries - in East Africa - is very strong.

And part of the subject of the visit is to continue to strengthen those ties to make them more effective. Third, as I wind down my presidency, I've already had a number of visits to Africa. But this gives me an opportunity to focus on a region that I have not been visiting as president, and I'm also going to have the opportunity to talk to the African Union.

So I'll be the first US president to not only visit Kenya and Ethiopia, but also to address the continent as a whole, building off the African summit that we did here which was historic and has, I think, deepened the kinds of already strong relationships that we have across the continent.

SOPEL: And you're going to talk about entrepreneurship at this summit in Nairobi.

OBAMA: Uh-huh.

SOPEL: Is there any link between security and entrepreneurship?

OBAMA: I think there is. I believe that when people see opportunity, when they have a sense of control of their own destiny, then they're less vulnerable to the propaganda and twisted ideologies that have been attracting young people - particularly now being turbocharged through social media.

Image copyright Amanda Lucidon/White House Image caption Photo by Amanda Lucidon/White House

And a while back, when we started looking at strategies to reach out to the Muslim world - to reach out to - developed countries, a common theme emerged, which was people are not interested in - just being patrons- or - or being patronised. And being given aid. They're interested in building capacity.

The more we can encourage entrepreneurship, particularly for young people, the more they have hope. Now that requires some reforms in these governments that we continue to emphasise. Rooting out corruption, increased transparency and how government operates, making sure that regulations are not designed just to advantage elites, but are allowing people who have a good idea to get out there and get things done.

SOPEL: And I suppose the - you know, you famously said when you went to Africa, I think when you first became president, you know, "What we need is strong institutions and- "

OBAMA: Yes.

SOPEL: " - not strong men". You're going to Ethiopia, where there is effectively no opposition in Parliament.

OBAMA: Right.

SOPEL: You're going to Kenya, where the International Criminal Court is still investigating certain members of the government, which seems kind of hardly ideal institutions.

OBAMA: Well, they're not ideal institutions. But what we found is, is that when we combined blunt talk with engagement, that gives us the best opportunity to influence and open up space for civil society. And the human rights agenda that we think is so important. And, you know, a good example of this is Burma. Where I was the first US president to visit there.

At a time when we saw some possibility of transition, by the time I landed in Burma - it is not a liberal democracy by any means. And there were still significant human rights violations taking place. But my visit then solidified and validated the work of dissenters and human rights activists.

And that has continued to allow them to move in the direction of a democracy. So, so our view is, in the same way that I visited Russia, and in the same way that I visited China, even when we know that there are significant human rights violations taking place, we want to make sure that we're there so that we can have this conversation and point them in a better direction.

SOPEL: Well, haven't the Chinese got there first in Africa? You're going to go to the African Union Building, which was built with Chinese money, you're going to travel along Chinese-built roads, you're going to go past endless Chinese traders on those roads.

OBAMA: Well, the - what is true is that China has - over the last several years, because of the surplus that they've accumulated in global trade and the fact that they're not accountable to their constituencies, have been able to funnel an awful lot of money into Africa, basically in exchange for raw materials that are being extracted from Africa.

And what is certainly true is that the United States has to have a presence to promote the values that we care about. We welcome Chinese aid into Africa. I think we think that's a good thing. We don't want to discourage it. As I've said before, what I also want to make sure though is that trade is benefiting the ordinary Kenyan and the ordinary Ethiopian and the ordinary Guinean and not just a few elites. And the Chinese, who then get the resources that they need. And I think that we can help to shape an agenda where China, Europe, and the United States are all working together in order to address some of these issues.

SOPEL: I'm going to suggest there may be one other difficult issue when you're there. And that's the issue of homosexuality, gay marriage, after the Supreme Court ruling. I mean, the deputy president in Kenya, who you're going to meet, Mr Ruto, he said - "We have heard that in the US they have allowed gay relations and other dirty things."

OBAMA: Yeah. Well, I disagree with him on that, don't I? And I've had this experience before when we've visited Senegal in my last trip to Africa. I think that the president there President Sall, is doing a wonderful job in moving the country forward - a strong democrat. But in a press conference, I was very blunt about my belief that everybody deserves fair treatment, equal treatment in the eyes of the law and the state.

And that includes gays, lesbians, transgender persons. I am not a fan of discrimination and bullying of anybody on the basis of race, on the basis of religion, on the basis of sexual orientation or gender. And I think that this is actually part and parcel of the agenda that's also going to be front and centre, and that is how are we treating women and girls.

And as somebody who has family in Kenya and knows the history of how the country so often is held back because women and girls are not treated fairly, I think those same values apply when it comes to different sexual orientations.

The next step of the Iran nuclear deal

SOPEL: Can we just move from difficult conversations that you're about to have in Kenya and the excruciatingly difficult conversations that you had in getting the Iran nuclear deal? I'm sure some people would say that yes, you've set out the case where there is no pathway to a nuclear bomb now for Iran -

OBAMA: Yes.

SOPEL: But, the net effect of lifting sanctions is that billions more will go to groups like Hezbollah, the Assad regime, and that is going to destabilise the region even more.

OBAMA: Well, keep in mind, first of all, we've shut off the pathways for Iran getting a nuclear weapon, which was priority number one. Because if Iran obtained a nuclear weapon, then they could cause all those same problems that you just listed with the protection of a nuclear bomb. And create much greater strategic challenges for the United States, for Israel, for our Gulf allies, for our European allies.

Second, it is true that by definition, in a negotiation and a deal like this, Iran gets something out of it. The sanctions regime that we put in place with the hope of the Brits, but also the Chinese and the Russians and others meant that they had funds that were frozen. They get those funds back. A large portion of those funds are going to have to be used for them to rebuild their economy.

That was the mandate that elected Rouhani. And the supreme leader is feeling pressure there. Does the IRGC [Revolutionary Guard] or the Quds Force have more resources? Probably, as the economy in Iran improves. But the challenge that we've had, when it comes to Hezbollah, for example, aiming rockets into Israel is not a shortage of resources.

Iran has shown itself to be willing, even in the midst of real hardship, to fund what they consider to be strategy priorities. The challenge is us making sure that we've got the interdiction capacity, the intelligence, that we are building a much stronger defence against some of these proxy wars and asymmetric efforts. And we've sent a clear message to the Iranians. We are settling the Iran deal, but we still have a big account that we're going to have to work. Hopefully some of it diplomatically, if necessary some of it militarily.

SOPEL: And you've had an intense campaign to settle the argument, which you've set out with great confidence.

OBAMA: Yes.

SOPEL: Have you managed to change anyone's mind yet of the Gulf states or in Congress?

OBAMA: Well, in Congress I'm confident that we're going to be able to make sure that the deal sticks. With respect to the Gulf states we had the leaders up to Camp David. And I described for them our interest in making sure that they built their capacity to defend themselves and their territory and to make sure that destabilising activities that Iran may be engaging in are checked. But keep in mind, our Gulf partners, for example, their combined defense budget is ten times Iran's defense budget.

SOPEL: But have they got the willingness to fight in the -

OBAMA: Well, and - and - and that's the issue. And that's the challenge as - so the point that I made to them consistently is, you have a strong, reliable partner in the United States. But ultimately, how issues get resolved in the Middle East is going to depend on both strengthening military capacity, but also addressing the underlying social and political issues that may lead not only to Iran being able to stir up problems among Shia populations, but also addressing some of the issues that are leading to the enormous and significant threat that they face from ISIL.

The UK and IS air strikes

SOPEL: Nowhere is facing greater instability, and you mention ISIL, than in Syria. It looks like the British may be about to start flying alongside America and launching airstrikes. Would you welcome that?

OBAMA: Let me first of all say that Prime Minister David Cameron's been an outstanding partner of ours on not just the anti-ISIL coalition, but on a whole host of security issues. And I want to congratulate his government for meeting the commitment of the 2% defence budget. Because we don't have a more important partner than Great Britain.

And for him to make that commitment, when he has a budget agenda that is, you know confined, a budget envelope that is confined, is really significant. And it is important for British leadership, but it's important for US stability. Now, with respect to Syria, we consult closely, Britain's one of the leading members of the 60-nation coalition that's addressing ISIL.

In combination with the Turks and the Jordanians and others, what we are trying to do is not only shrink the environment in which ISIL can operate, but also to create an environment in which we stop the border flows of foreign fighters into Syria, we've made progress there, we need to make more, and that's where Great Britain's participation can help.

Image copyright White House/Amanda Lucidon Image caption Photo by Amanda Lucidon/White House

But the second part of this is pushing Assad, the Russians, the Iranians, into recognising there's got to be a political transition before Syria pulls the entire region into what could be an even longer and more bloody conflict.

SOPEL: You talk about the 2% defence spending in Britain. I'm right in thinking that there was quite a bit of pressure put on from here, saying it would be very bad if you didn't.

OBAMA: I wouldn't say pressure. I think I had an honest conversation with David that Great Britain has always been our best partner. Well, you know, I guess you could go back to 1812 and that would (LAUGH) you know, that -

SOPEL: When we tried to burn this place down?

OBAMA: Yeah, right, right. But that's ancient history -

SOPEL: History.

OBAMA: In modern times there's no country where we have closer affinity in terms of values, and on the international stage a nation with greater capacity. And so I think David understands that part of the greatness of Great Britain, of the United Kingdom is that it is willing, as we are, to project power beyond our immediate self-interests to make this a more orderly, safer world.

SOPEL: And pe--

OBAMA: And we're glad we have that partner.

Leaving the EU

SOPEL: And people have talked about strategic shrinkage. That Britain is no longer playing its place on the world stage in the way that it used to. There's going to be a referendum on whether we stay in the European Union or not. And David Miliband, the former foreign secretary, he said, "It's almost like Britain would be resigning from the world and no US government would be impressed by that."

OBAMA: Well, I - you know, obviously the - the whole debate that's been taking place about the European Union, the eurozone, Greece that's a complicated piece of business. I will say this, that having the United Kingdom in the European Union gives us much greater confidence about the strength of the transatlantic union and is part of the cornerstone of institutions built after World War II that has made the world safer and more prosperous.

And we want to make sure that United Kingdom continues to have that influence. Because we believe that the values that we share are the right ones, not just for ourselves, but for Europe as a whole and the world as a whole.

Obama's legacy

SOPEL: Can we just talk about, because you mentioned a moment ago about that you're in the tail end of your presidency. After the midterm elections, I read every commentator say, "Well, this administration is effectively over now. The president is a dead man walking. And nothing is going to happen until 2016."

OBAMA: Right.

SOPEL: Except that you've kind of got this deal, you've got Cuba, diplomatic relations, healthcare reform embedded, major trade deal with Asia. It's not a question of journalist--

OBAMA: Climate change agenda with China.

SOPEL: Okay, so it's not -

OBAMA: I've got a pretty long list.

SOPEL: Okay, so it's not a question that a journalist often asks, what's gone right?

OBAMA: (LAUGH) You know the - it's interesting - that one of my - every president, every leader has strengths and weaknesses. One of my strengths is I have a pretty even temperament. I don't get too high when it's high and I don't get too low when it's low. And what I found during the course of the presidency, and I suppose this is true in life, is that investments and work that you make back here sometimes take a little longer than the 24-hour news cycle to bear fruit.

So some of this is just some serendipity and convergence of a lot of things that we had been working on for a very long time coming together. But some of it is I also believe a recognition that the kind of gridlock and obstruction that that Congress and the Republicans in Congress too often have engaged in is something that we just can't afford at a time when the world is moving so fast and there are so many challenges. And the robust exertion of executive authority within the the lawful constraints that we operate under is something that we've been spending a lot of time thinking about.

SOPEL: Let me just ask you this - finally, because- I'm sure you would like it to be written that President Obama turned "Yes we can" into -

OBAMA: "Yes we did."

SOPEL: "Yes we did."

OBAMA: Yeah.

Unfinished business

SOPEL: But is there an issue that there are be going to be unfinished business? Perhaps most notably on race and on guns by the time you leave the White House?

OBAMA: There will be. Look there was never a promise that race relations in America would be entirely resolved during my presidency or anybody's presidency. I mean, this has been a running thread - and - and fault line in American life and American politics since its founding.

And so some of the most recent concerns around policing and mass incarcerations are legitimate and deserve intense attention. And I feel that we are moving the ball forward on those issues. What I will say is that - eight years - well, after eight years of my presidency, that children growing up during these eight years will have a different view of race relations in this country and what's possible.

Black children, white children, Latino children. America is becoming more diverse, it's becoming more tolerant as a consequence there's more interactions between groups. There are going be tensions that arise. But if you look at my daughters' generation, they have an attitude about race that's entirely different than even my generation.

And that's all for the good. You mentioned the issue of guns, that is an area where if you ask me where has been the one area where I feel that I've been most frustrated and most stymied it is the fact that the United States of America is the one advanced nation on earth in which we do not have sufficient common-sense, gun-safety laws. Even in the face of repeated mass killings.

And you know, if you look at the number of Americans killed since 9/11 by terrorism, it's less than 100. If you look at the number that have been killed by gun violence, it's in the tens of thousands. And for us not to be able to resolve that issue has been something that is distressing. But it is not something that I intend to stop working on in the remaining 18 months.

SOPEL: Mr President, thank you very much.

OBAMA: Thank you so much. I enjoyed it.