Assembly members have backed a call for a new referendum on whatever terms are proposed for Brexit, with the option of staying in the EU on the ballot paper.
Labour AMs supported the successful Plaid Cymru motion against Tory, Brexit Party and UKIP opposition.
Plaid Cymru's Delyth Jewell told the Senedd: "The most democratic thing is to give the people a final say."
But Tory Darren Millar said "you cannot call for another vote because you don't like the outcome" of the 2016 poll.
The vote on the motion, which is purely symbolic, came as contenders to replace Theresa May as Conservative leader and prime minister set out their Brexit positions, with the UK due to leave the European Union on 31 October.
It follows a decision by the Labour Welsh Government to support a further vote, after an EU election result where the party came third in Wales.
A total of 36 AMs backed the Plaid motion, versus 16 against.
Mrs May had promised Brexit day would be 29 March, but it was postponed after MPs failed to back the divorce deal she negotiated with EU leaders.
Opening Wednesday's debate, calling for a "confirmatory referendum" on any Brexit deal, Ms Jewell said: "There is still time to step back from the brink, to protect the £245m Wales receives every year from being in the EU.
"Time to protect out industries, time to reaffirm workers' rights, time to take the path that offers the best and brightest future for Wales and our citizens by choosing to remain in the EU, it is not too late."
Following the shift in the Welsh Government's Brexit position, Counsel General Jeremy Miles said: "We are making clear now that we will campaign remorselessly to remain and we need parliamentarians of all parties to recognise the only way forward is to legislate for another referendum.
"The UK government should be taking the necessary steps to prepare for another referendum now. Drafting the relevant legislation, consulting the electoral commission and seeking agreement to another extension to the Article 50 process."
Labour Torfaen AM Lynne Neagle said the UK had "had enough of being held to ransom by an intra-party melodrama on Europe".
"Whether you want to stay in the EU or leave the there is only one way to break the Brexit deadlock, and that is to respect the people and give the people a final say."
Mark Reckless, assembly leader of the Brexit Party, which came top in last month's European elections, called on the next prime minister to "carry out the wishes of the people and to leave the EU no later than the 31st of October 2019".
"That is to respect democracy," he said.
"We must ensure in out country the people who respect democracy win over those who wish to block Brexit and deny democracy."
Making a similar argument, Conservative Clwyd West AM Darren Millar it was wrong to "call for another vote because you don't like the outcome" of the 2016 referendum on the EU.
"I urge everybody who respects democracy to reject this ridiculous motion from Plaid Cymru and to support our amendment which makes it clear that the outcome of referendums should always be implemented when we put these questions to the people," he said.
Despite his efforts, assembly members backed the motion to give "unequivocal support for a confirmatory referendum" that goes further than a previous call by Labour and Plaid Cymru AMs in January for work to begin to prepare for another referendum.
But the power to introduce a referendum rests with MPs and the UK government in Westminster.