Labour is set to stay in power in Wales after matching its best-ever Senedd election result, with exactly half of the 60 seats in the Welsh Parliament.
The Tories took the Vale of Clwyd from Labour, and Brecon and Radnorshire from the Liberal Democrats.
Labour held firm in other Tory target seats and took Rhondda back from Plaid Cymru.
Leader Mark Drakeford, who extended the majority in his seat, vowed to form a "stable and progressive" government.
With 52 of the 60 seats declared, Labour is on 30 with the Conservatives on 12, Plaid Cymru nine and the Liberal Democrats one.
It is unlikely Labour will gain further seats when votes for the regional lists in South Wales Central and South Wales East are counted on Saturday, after the party won the lion's share of constituency seats there.
Current first minister Mr Drakeford, who raised his majority in his Cardiff West seat by 12.7 points and more than 6,000 votes, told BBC Wales he would "do whatever I can" to ensure Wales has a "stable and progressive" government.
He added he would prefer to be in a position "where you have a government that is able to command a majority for the action that it needs to take on the floor of the Senedd".
He added: "Without trying to rush a decision at this time on a Friday we'll take a couple of days to make sure that we make the best decision that we can for Wales."
Leanne Wood's win in the Rhondda was one of the shocks of the 2016 Senedd election— BBC Wales News (@BBCWalesNews) May 7, 2021
Now Labour's Buffy Williams has won it back with a 19% swing #BBCElections
Live coverage: https://t.co/fWhIHJIpme pic.twitter.com/0aFFFbm8nJ
Labour also regained Rhondda from Plaid Cymru, toppling its former leader Leanne Wood.
Her win there in 2016 was one of the major upsets of the last Senedd election but Labour's Buffy Williams overturned it with a 19% swing and a majority of more than 5,000.
Ben Lake, the Plaid Cymru MP for Ceredigion, said losing the Rhondda seat was a "terrible blow for the party".
Asked if the party could still play a role in a coalition with Labour if required, he said it was a "dead duck".
"The people of Wales have sent a very clear message at the election, and I can't see it being feasible or indeed desirable on the part of either party," he told BBC Radio Wales Breakfast.
Plaid Cymru has won five constituency seats, holding on to Arfon, Dwyfor Meirionnydd, Ynys Mon, Ceredigion, and Carmarthen East and Dinefwr.
With three of the five regional list results declared so far, Plaid has won four list seats, the Conservatives four, Labour three and the Liberal Democrats one.
The Conservatives held on to Montgomeryshire, Aberconwy, Clwyd West, Carmarthen West and South Pembrokeshire, and Preseli Pembrokeshire.
The party also kept Monmouth where ex-Monmouthshire council leader Peter Fox is its new incumbent following the deselection of Nick Ramsay.
But the Tories failed to capture the Vale of Glamorgan, another Labour-held target seat which is Conservative at Westminster.
The Labour seats of Alyn and Deeside, Gower, Swansea East, Swansea West, Neath, Aberavon, Ogmore, Bridgend, Cynon Valley, Pontypridd, Cardiff Central, Cardiff North, Cardiff South and Penarth, Cardiff West, Caerphilly, Islwyn, Merthyr Tydfil and Rhymney, Newport East, Newport West and Torfaen have also remained red.
Labour also held on to the Plaid Cymru target seat of Llanelli, with Welsh government deputy transport minister Lee Waters being re-elected.
Following his victory, Mr Waters said Mark Drakeford was "definitely an asset", due to his leadership during the pandemic.
"He may not be flashy, he may be a bit nerdy, a bit boring, he's a university professor, but thank God for him," he said.
Health Minister Vaughan Gething also paid tribute to his party leader, saying: "The recognition of the way Mark has run the Welsh government in this extraordinary time was undoubtedly a factor in the way that people have voted."
Despite the challenges of the pandemic, more than 1.1 million people voted, making it the highest-ever turnout for a Senedd election at 46.6%.
This beat the previous record of 46.3% at the first Senedd election in 1999, but is still significantly lower than turnout for general elections.
Welsh Labour 'astonishingly resilient'
Laura McAllister, professor of public policy at Cardiff University, said Labour had "performed better than most people expected".
"After 22 years in power, with a Conservative Party that was really strongly tipped to make significant breakthroughs, and of course Plaid Cymru biting its ankles as well, that's some achievement."
Political commentator Prof Roger Awan-Scully said: "I think it's been an astonishingly resilient performance by the Welsh Labour Party, amidst disasters for Labour elsewhere in the UK.
"The Conservatives are also performing strongly, but not quite bringing it home in terms of the number of constituency victories that they might have expected.
"For Plaid Cymru I think this has to be said to be a deeply disappointing election."
The Vale of Clwyd was the only Conservative gain in Labour's "red wall" of seats in north Wales where the Tories had enjoyed success in the 2019 General Election.
Winning candidate Gareth Davies, an NHS physiotherapist, said: "It's a magnificent achievement.
"In 1999 I was a small boy, and now I'm in my 30s and I never thought back then I'd ever be in this position. So I feel really humbled."
Andrew RT Davies, leader of the Tories in the Senedd, said the result in the Vale of Clwyd was "fantastic".
North Wales has been a fiercely contested battleground, with re-elected Aberconwy Tory MS Janet Finch-Saunders saying she had been "horrified" by personal attacks which had hurt her family during the campaign.
Labour's win in Alyn and Deeside represents the last of the red wall seats that the Conservatives had hoped to take in north east Wales.
It's the last brick in the wall.
But they have only managed in this election to take Vale of Clwyd in that region - by a small amount.
So it counts as a disappointing set of results for the Conservatives.
How many members are being elected?
Labour, which has been in charge of the Welsh government for 22 years, is now set to remain in power for a sixth term with exactly half the seats in the Senedd chamber.
Of the 60 members of the Senedd (MSs) being elected, 40 will serve constituencies and 20 will be elected to represent larger regional areas of North Wales, Mid and West Wales, South Wales West, South Wales Central and South Wales East.
A party needs to win 31 seats to claim a majority but it has never happened, with Labour last time having 29 seats.
It previously won 30 seats in 2003 and 2011.
For Plaid Cymru, the party's Westminster leader Liz Saville Roberts painted a gloomy picture for their hopes of making inroads into Labour's grip on the south Wales valleys.
She said the pandemic had meant "ministers in the governments, both in Westminster and Cardiff, have had an immense platform over the last year".
It had been an "extraordinarily different" election, Ms Saville Roberts said, "to anything that anybody has been used to, and it's been difficult for a party like Plaid to get the same sort of platform".
"At the same time there's a real sense that our policy, our offer of policies, has offered something that was progressive and new and is, I hope, really the seeds for something in the future," she added.
Adam Price, who held Carmarthen East and Dinefwr with a reduced majority, said he would not stand down as Plaid Cymru leader.
Despite no gains, Mr Price said the party had increased its share of the vote and its stance on independence had been a "net positive".
"I'm not walking away from anything, because this is the moment when Wales needs leadership," he said.
"This is a historic challenge, because of the way that the politics is moving in this island, but it's also a historic opportunity for us.
"We can move our nation forward and I'm looking forward to playing my part, it's not something that anyone can do on their own.
"I have a role to play, we all have a role to play and that's what's exciting about politics at the moment. Wales is on the move Wales is on the march. I'm going to be part of that."
Meanwhile, the Welsh Liberal Democrats lost their constituency seat in Brecon and Radnorshire but won a list seat in Mid and West Wales with party leader Jane Dodds heading for the Senedd.
Liberal Democrat peer Baroness Jenny Randerson said she did not think Welsh Labour would need the support of Ms Dodds to run a government as had happened with her predecessor, former Education Minister Kirsty Williams who stood down prior to the elections.
"I think Labour will have the numbers to just about manage on their own," said Baroness Randerson.
'Devastating pandemic impact'
Ian Price, director of CBI Wales, congratulated Labour.
"This is a critical time for the Welsh economy and the new parliament must have a laser-like focus on rebuilding from the devastating impact of the pandemic," he said.
"That means all parties pulling together and working with business to protect jobs, rebuild livelihoods and create a fair and sustainable recovery that addresses the longstanding structural challenges our economy faces."
The Abolish the Welsh Assembly Party was also hoping to make a breakthrough in the regional lists.
Voting also took place for four police and crime commissioners, with those votes to be counted on Sunday.
SIGN UP FOR WALES ALERTS: Get extra updates on BBC election coverage