Former independent AM John Marek has lost the Wrexham assembly seat he had held for the last eight years.
Dr Marek had represented Wrexham as MP and AM since 1983
Labour's Lesley Griffiths, who was Dr Marek's former constituency secretary, beat him by 1,250 votes.
Dr Marek, the town's former Labour MP originally won the assembly seat for the party in 1999, but converted to an independent four years ago.
The win could revive Labour's hopes of staying in power at the assembly.
Ms Griffiths said she believed she had won the seat because the people of Wrexham were appreciative of what Labour had done for them and personality had not come into it at all.
Lesley Griffiths said she won Wrexham on policy issues
She said:"It was about policy - what Labour have done and what Labour will do in the future."
The new AM said she wanted to be "a real voice for Wrexham" in the assembly and said she would be concentrating on affordable housing, a big issue in the town
Dr Marek, the assembly's deputy presiding officer, was elected Labour MP for Wrexham in 1983 but turned his attentions to the assembly when it was set up eight years ago.
He fell out with Labour and was deselected before the last assembly poll, and made history in 2003 by becoming the first independent AM, with a majority of over 1,000.
Later he set up the Forward Wales party in which he was joined by another former Labour AM and former Welsh Secretary Ron Davies.
Turnout in Wrexham was 38.6 per cent.