Nick Boles has resigned as Skills Minister just hours before Theresa May is due to succeed David Cameron as prime minister.

In a statement on Facebook, he said: "As David Cameron prepares to visit HM the Queen and tender his resignation I want to add my voice to those praising his remarkable service as Prime Minister and leader of the Conservative Party".

"It was a huge privilege to be part of his Government. I want to thank him for offering me the opportunity to serve my country. I believe that this is the right time for me to return to the back benches."

He offered his full support to the incoming prime minister "as she strives to make Britain a place that works for everyone, not just a privileged few. It is a noble ambition and I wish her well."

Mr Boles was a key ally of Mr Cameron's during his bid to modernise the party in opposition between 2005 and 2010.

He campaigned on behalf of the Remain campaigner during the EU referendum and has notably supported Mr Cameron's intiatives such as same-sex marriage which were not supported by the grassroots membership.

In an comment piece for ConservativeHome on Sunday he said it was not true that modernisers like him were planning to leave the party.

He said: "The modernisation of the Conservative Party is a process, not an event, with different phases – and different emphases as it unfolds.

"Changing the social attitudes of the party so we learned how to treat women and gay people and people of different races and faiths with equal respect was a vital step, first pioneered by Theresa May as Party Chairman."

Theresa May: How her leadership speech differed from her voting record

While acting as Michael Gove's campaign manager during the Conservative leadership contest, Mr Boles texted potentially wavering Tories who had previously backed Ms May to ask them to back the Justice Secretary to block Andrea Leadsom from the run-off, saying it was "in the national interest".

In a text message to MPs, published by the Sun, he asked "I am seriously frightened about the risk of allowing Andrea Leadsom onto the membership ballot.

"Are we really confident that the membership won't vote for a fresh face who shares their attitudes about much of modern life? Like they did with IDS".

David Cameron's premiership - in pictures Show all 15 1 /15 David Cameron's premiership - in pictures David Cameron's premiership - in pictures Britain's Queen Elizabeth II greeting David Cameron at Buckingham Palace for an audience to invite him to be the next Prime Minister on 11 May 2010 PA David Cameron's premiership - in pictures Prime Minister David Cameron and his wife Samantha wave from the steps of Number 10 Downing Street on 11 May 2010 Getty Images David Cameron's premiership - in pictures On 12 May 2010 Prime Minister David Cameron said in a press conference with Lib Dem leader Nick Clegg, who was then deputy PM, they plan to "take Britain in a historic new direction" and Conservative-led coalition government would be united and provide "strong and stable" leadership Rex David Cameron's premiership - in pictures A decade ago, David Cameron visited the Arctic to witness the effects of climate change. However since coming to power in 2010, his government has gradually dropped down a succession of green policies David Cameron's premiership - in pictures Prime Minister David cameron told the then New York mayor Michael Bloomberg, the Queen had “purred down the line” after he told her Scotland had voted against independence in September 2014. He was forced to apologise for breaking constitutional convention Getty Images David Cameron's premiership - in pictures Britain's Prime Minister David Cameron greeted soldiers working on flood relief in York city centre after the river Ouse burst its banks, in northern England in December 2015 REUTERS David Cameron's premiership - in pictures Claims that David Cameron performed an obscene act with a dead pig and smoked cannabis during his studies at Oxford University spread around the world in September 2015. The extraordinary allegations were made in an unauthorised biography of the Prime Minister written by Lord Ashcroft David Hartley/REX Shutterstock David Cameron's premiership - in pictures In 2016, Mr Cameron was caught up in a worldwide scandal dubbed the “Panama papers” Reuters David Cameron's premiership - in pictures Prime minister David Cameron and his wife Samantha with seven week old Regan as they meet her parents, first time home buyers Robert Arron and Kelly Jeffers at the Heritage Brook housing development in Chorley, Lancashire. David Cameron has joked that he wants "another baby" and said that he feels a "bit broody" every time he sees a newborn on the campaign trail David Cameron's premiership - in pictures Prime Minister David Cameron was criticised for branding refugees in the Calais ‘jungle’ camp as a “bunch of migrants” in January 2016 after thousands of refugees died in their attempt to cross the Mediterranean in 2015 Sky News David Cameron's premiership - in pictures Britain's Prime Minister David Cameron speaks with European Commission President Jean-Claude Juncker during an EU summit meeting on 17 March 2016 at the European Union council in Brussels. Cameron was in Brussels to renegotiate deal of UK membership with other European leaders. The deal, sealed after hours of haggling at a marathon summit, paved the way for a referendum on whether Britain will stay in the EU AFP/Getty Images David Cameron's premiership - in pictures President Barack Obama shakes hands with British Prime Minister David Cameron at a meeting at 10 Downing Street in London on 22 April 2016. The President and his wife visited 10 Downing Street where he joined press conference with British Prime Minister David Cameron and made his case for the UK to remain inside the European Union Getty Images David Cameron's premiership - in pictures After David returned from Brussels claiming victory in his renegotiation with European leaders, Boris Johnson announced that he will not support the Remain campaign. The prime minister said publicly he was "disappointed but Boris remains a friend" PA David Cameron's premiership - in pictures Prime Minister David Cameron makes a joint appearance with Mayor of London Sadiq Khan as they launch the Britain Stronger in Europe guarantee card at Roehampton University on 20 May 2016 in London. The 'guarantee card' lists five pledges should Britain remain in the EU, including the protection of workers' rights, full access to the single market and stability for Britain David Cameron's premiership - in pictures Britain's Prime Minister David Cameron speaks outside 10 Downing Street on 24 June 2016. Cameron announced his resignation after Britain voted to leave the European Union after a bitterly divisive referendum campaign AP

Ms May won 199 of the votes cast by the party's MPs but the Energy Minister and Brexiteer came second on 84 after the second ballot. Mr Gove came third on 46 - two fewer than he had received in the first round.