It has not always been easy. Buffeted by the winds of austerity and the scepticism of his more insular backbenchers, compromising on the 0.7 per cent of gross domestic product (GDP) that we contribute as overseas aid must, at times, have seemed an attractive option.

To his lasting credit, the prime minister has not taken that option. And those of us who spend our professional lives attempting to build a fairer, more sustainable world owe him our gratitude for the courage he has shown.

For my part, I am preparing to step down after 12 years heading the International Institute for Environment and Development, which has been working to build sustainable development in many countries across the world for more than 40 years. So questions of legacy are not far from my mind.

As David Cameron enters his last few years in office, having said publicly that he will not be prime minister come the end of this parliament, legacy is an issue that may be playing in his mind too.

A sustainable future

The good news is that he has a sequence of extraordinary opportunities over the next few months to secure his place in history as a champion of our planet's poorer citizens.

In September, at the United Nations, governments are due to agree a new set of sustainable development goals (SDGs), which will better the lot of those living in poverty while preventing such growth trashing the planet's ecological health. Last week, speaking at the European Development Days in Brussels, Melinda Gates said she sees agreement of the SDGs as the most important moment in a generation.

The phrase 'sustainable development' provokes some commentators to apoplexy, but there is a very simple response. Just imagine a world in which nine billion people live in societies that are developing unsustainably – using more resources than the world can provide, stamping their physical footprint ever harder onto nature, producing more pollution than the atmosphere and ocean can handle – and ask "is this a fitting bequest to our children?"

Cameron jointly chaired, with Presidents Johnson-Sirleaf of Liberia and Yudhoyono of Indonesia, the UN High-Level Panel that helped shape the ambition and architecture of the SDGs. Consistency now demands that the UK presses firmly for a strong set of goals, on health, education, poverty alleviation and the environment, and helps set the world economy and its poorest citizens on a trajectory towards better lives.

Secure climate

By common consent, securing a healthy and prosperous future for all the world's people – rich and poor – depends on finding an effective response to climate change.

In February, Cameron signed a joint pledge with the other main UK party leaders recognising climate change as "one of the most serious threats facing the world today… not just a threat to the environment, but also to our national and global security, to poverty eradication and economic prosperity".

He promised an adequate and coherent response to that threat at home and abroad, pledging to support a "fair, strong, legally binding global climate deal which limits temperature rises to below 2 degrees Celsuis", and to develop a low-carbon economy in the UK, including an end to use of coal for electricity generation.

The pledge is internally consistent. Developed nations have to implement strong decarbonisation policies if the developing world is to agree a global climate deal that stands a chance of keeping average warming below 2 degrees; without firm action at home, western words will have little impact abroad.

Joining all the dots

The 'global deal' is due to be finalised at the annual UN climate summit in Paris in December. But the diplomacy leading up to the summit has a really big moment this weekend, when the G7 leaders get together in Germany. It is an ideal opportunity for Cameron to show that his commitment to an effective climate deal is rock-solid.

On the really big questions such as climate and trade, G7 countries set the tone for all others. As I know from a lifetime of listening to ministers and citizens in developing nations, strong commitments from the developed world's biggest economies set the direction, and show the rest that the rich are serious.

Some other G7 nations, however, are not on the same page as the UK when it comes to climate change and helping the poor. Japan, for example, is planning to build new coal-fired power stations at home and abroad. It is pledging cuts in greenhouse gas emissions that are so shallow they would be laughable were the implications not so serious.

Robust advocacy within the G7 from Cameron for a strong set of SDGs and an ambitious climate change deal would show that he is as serious and consistent in his commitment to tackling global poverty and climate change as he has been on the delivery of UKAid.

In the final years of a leader's time, it is right to focus on those issues that really matter. Improving prospects for the world's poor, through building a sustainable global system that links poverty eradication and a stable climate, is just about the most important of all.

Cameron's legacy is within reach; he will be remembered well, should he decide to grasp it. Take courage Mr Cameron, and you'll find many who know this is right.