Thirty-eight Conservative rebels backed an amendment to end the Chinese firm's participation in the project by the start of 2023.
Despite promises from the government of a new bill to address their concerns, rebel MPs pushed their plan to a vote.
But with a large Commons majority, the government defeated it by 24 votes.
Culture Minister Matt Warman said the government had heard the points "loud and clear".
He added: "We will now engage intensively with colleagues across the House to make sure that we will make our case at every possible level…and we will underline that we will always put national security at the very top of our agenda."
The use of Huawei technology in the 5G network was signed off by No 10 and security experts earlier this year, with the caveats of keeping the kit out of the most sensitive areas and capping its market share at 35%.
But Tory critics say the firm is an arm of the Chinese state and a risk to UK security - claims the firm rejects.
Other countries, including the US and Australia, have banned Huawei from their own networks and criticised the UK's decision.
After the Commons vote, Huawei vice president Victor Zhang, said: "An evidence-based approach is needed, so we were disappointed to hear some groundless accusations asserted.
"The industry and experts agree that banning Huawei equipment would leave Britain less secure, less productive and less innovative."
A group of Tory MPs, led by the party's former leader Sir Iain Duncan Smith, put forward an amendment to the Telecommunications Infrastructure Bill to try and stop Huawei's involvement.
The amendment would have seen firms classified as "high-risk vendors" by the National Cyber Security Centre be banned entirely from the UK's 5G project by 31 December 2022.
Sir Iain said he and his colleagues were "genuinely concerned that this country has got itself far too bound in to a process in which we are reliant on untrusted vendors".
Speaking in the Commons, the backbencher accused the Chinese government of spending 20 years "underbidding" other technology firms until Huawei dominated the market, and the outcome was a risk to the UK's security.
He said using Huawei's technology was a "statement of absence of thought by any government", adding: "If defence of the realm is our number one priority, then this becomes demi-defence of the realm, and I am simply not prepared to put up with that."
Culture Secretary Oliver Dowden tried to reassure the group of backbenchers with the promise of bringing forward a Telecoms Security Bill before the summer recess "so all honourable members will be able to debate these points extensively".
He also said the government wanted to work with its Five Eyes security partners - including the US - on alternative solutions so the UK could "get to a position where we do not have to use high-risk vendors at all".
But Mr Dowden could not give a timetable for the exclusion of such companies, except to say it would be "in this Parliament" - meaning within the next five years.
As a result, Sir Iain pushed his amendment to a vote, marking the first Tory rebellion against the government since Boris Johnson won the election in December.
However, while 282 MPs from across the House voted in favour of the amendment, 306 MPs voted against, defeating it.
There were 38 Conservative MPs who rebelled against their government by voting for the amendment - including former international trade secretary Liam Fox, ex-Brexit secretary David Davis and former housing minister Esther McVey.
Conservative MP and Foreign Affairs Committee chairman, Tom Tugendhat, also voted in favour of the amendment, saying he did "not get the commitments" he wanted from the government.
"I am sorry that I could not support the government. I hope the policy will change before we come to the main Telecoms Security Bill before the summer."
The Telecommunications Infrastructure Bill later passed without needing a vote.