Jo Swinson will step down as Liberal Democrat leader after losing her seat to the SNP by 149 votes.
Ms Swinson, who started the campaign saying she could become the next prime minister, gained 19,523 votes compared with 19,672 for the SNP's Amy Callaghan in Dunbartonshire East.
Sir Ed Davey and Baroness Sal Brinton will be acting co-leaders for the party, now she is no longer an MP.
Ms Swinson said the election results would bring "dismay" for many.
She said she was "proud that Liberal Democrats were the unapologetic voice of Remain" in the election, adding that she did "not regret trying everything" to avoid Brexit.
Under party rules, the Lib Dem leader must have a seat in the Commons. A leadership contest will be held in the new year.
With all seats now declared, the party has 11 seats, one fewer than at the 2017 election.
News of Ms Swinson's defeat was cheered by Nicola Sturgeon, who was caught on camera celebrating the SNP's victory in Dunbartonshire East.
The SNP leader, who was waiting to speak to Sky News when the election result was read out, could be seen cheering as she found out that Ms Callaghan had won the seat.
Ms Sturgeon later offered her commiserations to Ms Swinson on a personal level, but said she was delighted by the SNP's performance.
Baroness Brinton, president of the Liberal Democrats and the new co-leader, said it was a "disappointing night" for the party.
"The voices of nationalism and populism both north and south of the border beat both her [Ms Swinson] in her seat and nationally as well."
She said there were some "nuggets of gold" the party could take from the election, such as increasing its share of the vote by 4.2% and getting "some good new MPs".
"All is not lost," she added, pledging that the party's MPs would "continue to fight, if not for our place in Europe, then for the best deal possible".
Earlier, Baroness Brinton thanked Ms Swinson, who only became Lib Dem leader in July, for what she called her honest and fearless leadership of their party.
The Liberal Democrats entered this election buoyed by a revival in the polls and the addition to their ranks of numerous MPs who defected from other parties, including Chuka Umunna and Luciana Berger from Labour, and the former Tory minister Sam Gyimah.
All three, however, were defeated.
Earlier, Sir John Curtice, professor of politics at Strathclyde University, said the polls suggested the party's support declined during the election and indicated that the strongly anti-Brexit party did not make any progress at all among Leave voters.
On the night, the Conservatives won a big majority and the SNP took 48 of Scotland's 59 seats, as Labour suffered heavy losses.
One highlight for the Lib Dems was the party's candidate in Richmond Park, Sarah Olney, winning the seat from the Conservatives' Zac Goldsmith.
Speaking at the Bishopbriggs count outside Glasgow following her defeat, Ms Swinson said the results were "very significant" for the future of the country.
"For millions of people in our country these results will bring dread and dismay and people are looking for hope.
"I still believe we, as a country, can be warm and generous, inclusive and open and that by working together with our nearest neighbours we can achieve so much more.
"Liberal Democrats will continue to stand up for these values that guide our Liberal movement - openness, fairness, inclusivity. We will stand up for hope."
The SNP's Ms Callaghan told BBC Scotland she was "delighted" to have unseated the Liberal Democrat leader.
The new MP said: "It's quite a momentous achievement, both for me personally but also in terms of the people of East Dunbartonshire, completely rejecting the politics of austerity and also giving the people a chance to choose their own future - I think that is incredibly important."
Ms Swinson became her party's first female leader in a landslide victory over Sir Ed Davey earlier this year, succeeding Sir Vince Cable.
She had served as a minister in the coalition government and was among the party's MPs who paid the price for the tie-up with David Cameron's Tories in the 2015 election - which saw the Lib Dems reduced to a rump of just eight in the Commons.
Ms Swinson fought back when then Prime Minister Theresa May called another election in 2017, and she regained her Scottish seat from the SNP.
She attracted criticism from some quarters for her policy to revoke Article 50 and cancel Brexit, and for her previous record in the coalition government.
The Lib Dems backed Boris Johnson's call in October for an early election, arguing it was the best way of stopping Brexit.
Mr Johnson focused relentlessly on a single message - "get Brexit done" - promising to take the UK out of the EU by 31 January 2020 if he got a majority.
If you cannot see the lookup tool, click here.