* Government says visit justified to further ties with U.S.
* Parliament debates 1.8 million-name petition opposing it
* Thousands of protesters rally outside (Recasts with comments from minister)
By William James and Alistair Smout
LONDON, Feb 20 (Reuters) - The British government on Monday defended its decision to offer U.S. President Donald Trump a lavish state visit and an audience with the queen this year, defying protests outside parliament and dissent from lawmakers.
Prime Minister Theresa May's government wants to reaffirm the "special relationship" with the United States and secure a trade deal as Britain prepares to leave the European Union.
"In the light of America's absolutely pivotal role we believe it entirely right that we should use all the tools at our disposal to build common ground with President Trump," junior foreign minister Alan Duncan told parliament.
He described state visits as Britain's "most important diplomatic tool", saying Trump's trip would go ahead as planned.
The visit has spurred 1.8 million people in Britain to sign a petition saying he should not be given a state visit because it could embarrass Queen Elizabeth.
As parliament debated that petition on Monday - a symbolic discussion which has no power to force the government to withdraw its invitation - around 7,000 protesters gathered outside with placards bearing slogans such as "Dump Trump, Fight Bigotry".
"It's about the rise of hate and extremism, which is personified by Trump. It's not just about him, but he represents what's happening in the world at the moment," protester Alison Dale, 61, told Reuters.
"The invitation was kneejerk, and made us look desperate. Now we're leaving the European Union, it's clear we're just desperate for trade deals, and we look weak."
Since taking office in January, Trump has sparked global protests over plans to ban migrants from seven Muslim-majority countries, and from women activists who call him misogynistic.
Trump says his immigration orders are aimed at protecting the United States and that his opponents have misrepresented his intentions.
Prime Minister May has said she will not consider cancelling the visit. Managing the backlash adds to her diplomatic "to-do" list as she sets about reuniting a country divided over Brexit and negotiating a divorce with European trading partners.
The debate, hosted in a packed side room of parliament rather than the main debating chamber, gave lawmakers a platform to air a wide range of views on Trump.
"It's difficult to know whether to be appalled at the morality of this invitation, or just astonished at the stupidity of the invitation," said Scottish National Party lawmaker Alex Salmond. Previously Trump has clashed with Salmond over his investments in Scotland.
Critics focused on accusations of sexism and referred to his immigration policies, while other lawmakers argued Trump should come to Britain, but should not be given the high honour of a state visit, which would involve lavish displays of royal pageantry and a banquet hosted by the queen.
Crispin Blunt, head of parliament's Foreign Affairs Committee, said a head-of-government visit by Trump would be appropriate this year but a full state visit should wait until 2020, the 400th anniversary of the Pilgrim Fathers' settlement in New England.
"If we don't take the hype out of this debate, with all the people who signed this petition, there is every possibility that of course this visit is then going to become a rallying point for everybody who is unhappy both with the direction of American policy, or British policy or anything else," he said.
(Editing by Guy Faulconbridge and Andrew Roche)