Adam Price has won the Plaid Cymru leadership contest, taking nearly 50 per cent of the vote.
The assembly member for Carmarthen East and Dinefwr defeated Rhun ap Iorwerth and former leader Leanne Wood in a ballot of party members.
Despite leading the party for six years, Ms Wood came last.
In his victory address at the Novotel in Cardiff, Mr Price said: "This election shows we are ready to lead again. Our time has come."
He told party members: "Our message must be simple. Yes, Wales can."
The AM is the first openly gay assembly party leader in the history of the institution and leads the third largest group in the Senedd, behind Labour and the Tories.
Mr Price, who has vowed to put independence at the core of his party's message, said: "There will be no second class travellers on our journey to a prosperous, self-confident and independent Wales."
"We must become the hope of those without hope."
Mr Price paid tribute to former leader Leanne Wood.
"She has inspired thousands with her drive, her resilience and her unending commitment to the causes that she and we hold dear," he said.
The leadership election began in the summer after Ynys Mon AM Mr ap Iorwerth and Mr Price challenged Ms Wood for her job.
The Rhondda AM, who became leader in 2012, left the count in Cardiff declining to give interviews. She later tweeted her congratulations to Mr Price.
Following the result Rhun ap Iorwerth said: "Now it's about coming together under the new leadership of Adam Price to take forward that joint vision that we have of a new Wales, a new more confident Wales, out to the public and build towards the next assembly election."
Adam Price took 49.7% of first preference votes (2,863), while Rhun ap Iorwerth took 28% (1,613) and Leanne Wood 22.3% (1,286).
After no candidate reached 50%, Ms Wood was knocked out and a second count began with the second preference votes of her supporters redistributed.
This gave Mr Price 618 more votes and Mr ap Iorwerth 348.
In the final totals, Mr Price beat Mr ap Iorwerth by 3,481 votes to 1,961.
By Felicity Evans, BBC Wales political editor
It's a bit of a shock to be honest.
Not because of who won - Adam Price was widely expected to take this - but because of the way the incumbent Leanne Wood lost.
It's a strange one, because she always polls as one of the most popular politicians in Wales.
She has UK recognition factor after taking part in general election TV debates, and yet somehow she has struggled to convert that popularity into widespread electoral success for Plaid Cymru.
Adam Price, a former MP, is perhaps best known for his attempt to impeach Tony Blair over the Iraq war in 2004.
Now in the assembly, he's a charismatic speaker, a big campaigner and a man of big ideas.
The pressure on him now will be to deliver on them.
Leader of the Conservative group in the assembly, Paul Davies, was one of the first to congratulate Mr Price on his victory, and said he looked forward to working with him in Cardiff Bay.
"I hope that Adam realises that Plaid members have now signalled a new direction. This is a clear instruction to end Welsh Labour rule and that they should no longer prop them up," Mr Davies said.
During the campaign candidates were questioned over whether they would work with the Conservatives in government.
Leanne Wood said Mr Price and Rhun ap Iorwerth would "quite possibly" strike a deal with the Conservatives, but Mr Price rejected the idea of a coalition with the party.
Adam Price told BBC Radio Cymru he did not want to enter a coalition with either the Conservatives or Labour.
"No to both unionist parties. Both have let the people of Wales down," he said.
Following the result Plaid Cymru's official Twitter account posted a video montage of Mr Price with dramatic music.
It was deleted after the video was widely mocked on the social media network.
Adam Price profile
- Born in Carmarthen to a miner's family in 1968. Educated at Ysgol Dyffryn Aman and Cardiff University
- Served as MP for Carmarthen East and Dinefwr from 2001 to 2010
- Awarded a Fulbright Scholarship to study at Harvard University during his break from politics
- Elected to the Welsh Assembly in 2016