Spain's governing Socialists won the country's third election in four years, but have fallen short of a
PM Pedro Sánchez's party polled 29% and will need the help of either left-wing Podemos and regional parties, or the centre right, to form a government.
For the first time since military rule ended in the 1970s, a far-right party, Vox, is set to enter parliament.
Vox opposes multiculturalism, unrestricted migration, and what it calls "radical feminism".
Analysts say support for Vox has been boosted by widespread anger at the Catalan independence drive. The party fervently opposes any concessions to the secessionists.
The other big story of the election was the collapse in support for the conservative Popular Party (PP), which governed Spain until it was dumped from power in May 2018 in a no-confidence vote.
In its worst election ever, the PP won just 66 seats, down from 137 in the previous parliament.
Turnout was 75.8%, the biggest for several years and 9% higher than the previous election in 2016.
In his victory speech, Mr Sánchez said the party's big challenges were to fight inequality, advance co-existence and halt corruption.
"The future has won and the past has lost," he told cheering supporters. During his time in office he has raised the minimum wage, appointed a female-dominated cabinet and promised to bring in laws defining rape as sex without clear consent.
The result is a personal success for the prime minister, who increased his party's share from 23% of the vote in 2016.
But it still leaves the Socialists and Podemos 11 seats short of the necessary 176 for a majority in the 350-seat parliament.
Mr Sánchez must now look for support from the smaller parties or from the centre right, but there is no easy solution.
An alliance with Ciudadanos (57 seats) would give him the numbers, but its leader, Albert Rivera, was bitterly critical of Mr Sánchez's collaboration with Catalan separatists, referring to his earlier "Frankenstein government" – and vowed he would not enter a coalition with the Socialists.
And as Mr Sánchez gave his victory speech late on Sunday, supporters chanted "Not with Rivera!", making it clear they also did not want a coalition with Ciudadanos.
The head of previous coalition partner Podemos, Pablo Iglesias, made clear on Sunday night that another left-wing administration was possible.
But the results appear to make any left-coalition dependent on Catalan pro-independence parties, which opponents on the right see as toxic.
An alliance involving all the other regional parties, including the Basque separatist PNV, would leave him one seat short of a majority.
All parties are now looking towards the regional and European elections in less than a month.
- Responsible immigration policies. Immigration should be legal, orderly and linked to work contracts and the wish to integrate and respect the customs of the nation. - Statute of temporary protection for Venezuelans, granting them temporary residency, freedom of movement and work permits. - Special plan to combat illegal immigration. - Support the work of social services in the care given to refugees who have fled dictatorships, wars or religious persecution. - Integration of legal migrants and advance policies which guarantee that second generations feel like full Spanish citizens. - Enable the recruitment of migrants in their own country.
- Access to Spanish citizenship by residency must be seen as a result of a process of integration of foreigners in Spain. - Prioritise countries in America and Africa for closer co-operation - Put in place a "state pact for safe, orderly and regular immigration". - Promote the common European asylum and immigration policy. - Promote full integration and equal opportunities for so-called second generations, paying special attention to education. - Reinforce a fair border policy.
- Establish legal and safe entry routes into Spain and guarantee the civil rights of migrants. - Make the process of family reunification, humanitarian visas and new visa programmes more flexible, such as job searches. - Reinforce the Maritime Rescue Service, which will remain as a public and civil service and whose sole function will be the safeguarding of life at sea. - Shut detention centres for foreigners (CIE). - Build a country without racism. - Promote a new asylum law that includes those who have to flee their homes because of environmental issues. - Guarantee that unaccompanied foreign minors receive treatment according to the Convention on the Rights of the Child.
- Set up a "points-based" immigration system to attract the best foreign talent. - Pursue mafia organisations that profit at the expense of the lives and safety of migrants. - Protect the officers of the state security forces that monitor our borders. - Increase resources for the state security forces dealing with irregular migration, reinforcing effective and non-aggressive action.
- Deport illegal migrants to their countries of origin. - Deport migrants who are legally in Spanish territory but who have committed minor offences or serious crimes. - Strengthen our borders. Build an insurmountable wall in Ceuta and Melilla (Spanish cities on the African continent bordering Morocco). - End the attraction: any migrant who enters Spain illegally will not be allowed to legalise their situation, ever. - Eliminate the "arraigo" process that allows illegal migrants to stay in Spain under exceptional circumstances. - Raise the levels of language ability, tax contributions and integration as requirements for citizenship.
- Approve a reduced fee for self-employed workers whose income does not exceed the minimum wage. - Encourage active aging and the voluntary extension of working life beyond the statutory retirement age. - Make the process of setting up companies easier. - Establish mechanisms that penalise unjustified temporary contracts. - Autonomous communities where PP is in power will reduce income tax for people under 35 and families with at least one child. - Eliminate inheritance tax for transactions between parents and children, and their descendants. - Pensions must maintain their purchasing power.
- Create ways of boosting co-responsibility and work-life balance. - Strengthen the progressivity of the tax system, increasing the contribution of large companies and taxpayers with higher incomes and larger assets. - Gradually increase the minimum wage. - Simplify and reorder the offer of employment contracts to three types: indefinite, temporary and training. - Modify the system for self-employed workers so that they can contribute according to their real income.
- 34-hour working week. - Work towards internet connection as a basic right, with free access. - Reach a minimum wage of €1,200 (US $1,350). - Strengthen anti-trust laws. - Penalise companies that make excessive use of temporary contracts. - Fight against tax havens. - Special unemployment protection for young people. - Restore rights for those in most vulnerable jobs, especially in sectors dominated by women.
- Guaranteed salary supplement to help workers in poverty and fight the abuse of the temporary contracts. - Self-employed workers whose real incomes are below the minimum annual salary will not pay contributions. - Promote a favourable legal framework for innovative companies in their initial stages. - Guarantee that suppliers are paid within a maximum of 30 days in public contracts or 60 days in other cases. - Eliminate temporary contracts: all contracts will be indefinite. - No-one will ever have to renounce an inheritance because they cannot pay inheritance tax.
-10% reduction of company contributions for new permanent contracts for Spanish workers. - Strong support for large families and the birth rate in general. - Support for self-employed workers. Zero contributions if income does not reach the minimum wage. 100% reduction in contributions if a self-employed worker is out of work. - Support for the unemployed aged over 50 and for the long-term unemployed. - Drastic reduction of income tax. - Elimination of property tax and inheritance tax.
- Local offices for Assistance for Pregnant Women so that no woman stops being a mother because of her economic, social or family circumstances. - Improve social protection and support for pregnant young women and young families, temporarily adapting, if necessary, their schooling, so that motherhood does not pose an obstacle. - Reform the penal code to extend the option of permanent remand to cases of murder in which some gender violence is suspected. - Training in equality and the fight against gender violence to be given to all professionals who might come across the issue in their career. - Plan to close the wage gap in Spain. - Encourage more women into the labour market to reach levels similar to the European average.
- End surrogacy (which is currently illegal in Spain). - Reform of the criminal code to ensure that the lack of explicit consent of the victim is key in sexual crimes. If a woman does not say yes, it means no. - Prohibit segregated education in schools supported by public funds. - In schools, promote the prevention of gender violence and respect for sexual diversity. - Reform gender identity law, eliminating the need for medical diagnoses and making it easier for under 16s to change name and sex records. - Allow non-transferable parental leave for both parents. - Implement urgent measures to ensure equal treatment and employment opportunities for women and men.
- Guarantee immediate housing alternatives for women and their children who suffer domestic violence. - Introduce feminism classes. - Equal and non-transferable paternity and maternity leave. - Offer help with assisted reproduction and facilitate access to the latest contraceptive methods, emergency contraception and voluntary terminations for all women. - Legal protection of trans people and the right to self-determination of gender identity and expression. - Establish equality in local authorities. - Launch a plan to fight domestic violence, with an annual allocation of €600m ($675m).
- End male-preference in the royal line of succession. - Protect marriage between LGTBI people and include the right to non-discrimination based on sexual orientation. - Approve a surrogacy law so that women who cannot conceive and LGTBI families can fulfill their dream of forming a family. - Expand maternity and paternity leave to up to 16 weeks for each parent. - Combat intolerance and hate speech, including on social networks. - Promote a greater presence of women in visible positions of responsibility, guaranteeing an equality balance in public office.
- Protection of life from conception to natural death. - Elimination of quotas (by sex or for any other reason) in electoral lists. - Repeal gender violence law and any rule that discriminates against a person's sex. Instead, enact a law of intra-family violence that protects the elderly, men, women and children alike. Suppression of subsidised "radical feminist" organisations, effective prosecution of false allegations. - Extension of maternity leave to 180 days that would be extended to one year in the case of children with disabilities.
- In accordance with article 155 of the Spanish constitution (which allows direct rule to be imposed on an autonomous region) apply, for as long as it is inexcusable, as many measures as necessary. - Reform the penal code to re-criminalise the call for an illegal referendum and reform the law of pardon to prohibit it for crimes of rebellion and sedition. - Promote the national holiday of 12 October across the whole of Spanish society and promote activities around it in all schools. - Impose sanctions on authorities that refuse to fly the national flag on all official buildings or ensure the portrait of the Head of State is present at plenary sessions of municipal councils. - Approve a moratorium that would paralyse the transfer of new powers to autonomous communities.
- Commit to continue building a Spain of autonomies. Strengthen the regional model as a fundamental instrument for recognising the uniqueness and political options of each autonomous community.
- Reach a democratic solution for the Catalan conflict. Hold a referendum, in which Podemos will defend a new role for Catalonia in Spain. - Reform the regional financing system, in dialogue with all autonomous communities.
- Activate Article 155 emergency powers (which allows direct rule to be imposed on an autonomous region) until the constitution in Catalonia can be restored. - Improve measures to protect Spaniards against coups in the 21st century. - Update the crime of sedition and rebellion in the penal code. - Launch classes on the Spanish constitution throughout Spain, and put an end to nationalist indoctrination in schools.
- Suspend Catalan autonomy until the unmitigated defeat of the coup. - Make illegal any party, association or NGO that pursues the destruction of the nation and its sovereignty. - Legal protection for the symbols of the nation, especially the flag, the anthem and the crown. Increase sentences for offences against Spain and its symbols or emblems. - Intensify diplomatic actions for the return of Gibraltar. - Comprehensive programme to protect national identity and raise awareness of Spain's contribution to civilisation and universal history, with special attention to the deeds and exploits of our national heroes.
Who are Vox?
The PP's historic defeat means that, even with the support of centre-right Ciudadanos (Citizens) and Vox, it has no chance of forming a right-wing coalition, and leader Pablo Casado said it would become the main opposition force.
But Vox saw its support surge, winning more than 10% of the vote, which gives it 24 seats.
Italy's deputy PM Matteo Salvini, from the right-wing League party, tweeted: "Congratulations to @Santi_ABASCAL and our friends in @vox_es for joining the Parliament in Spain".
France's far-right leader Marine Le Pen of the National Rally also offered her "warmest congratulations" to the "young and vigorous party".
"Nations need enthusiastic defenders!" she tweeted.
Led by Santiago Abascal, a former PP member, the party has emerged in a matter of months with a vow to "make Spain great again".
It won seats for the first time in local elections in the southern Andalusia region, and agreed to support a centre-right coalition of the PP and Ciudadanos.
In his speech after the results, Mr Abascal said: "We told you that we were starting a reconquest of Spain and that is exactly what we have done... and we can clearly say to all of Spain that Vox is here to stay."
Vox rejects the far-right label but its views on immigration and Islam place it in line with far-right and populist parties elsewhere in Europe.
It wants to repeal laws against gender violence, and opposes abortion and same-sex marriage. Critics see it as a nationalist throwback to the Franco era.
Vox aims to deport migrants legally entitled to be in Spain if they have committed an offence, and wants to prevent any migrant who comes in illegally from staying.
The BBC's James Reynolds says that fear of big gains for the far-right helped the Socialists to victory.
Why is Catalonia so important?
The future of Spain's semi-autonomous north-eastern region was one of the big issues of the election.
Catalonia held an independence referendum in October 2017 and then declared independence from Spain.
A dozen of its leaders have since gone on trial in Madrid, facing charges including rebellion and sedition. Among them is ERC leader Mr Junqueras, who was Catalan vice-president when he was arrested.
During last Monday's election debate, the leaders of the PP and Ciudadanos accused the prime minister of siding with "enemies of Spain" and wanting to "liquidate Spain".
The centre-left Catalan ERC was the big winner in Catalonia, with a projected 15 seats. Its leader, Oriol Junqueras, is in jail facing trial for his role in declaring independence in October 2017 and tweeted thanks for the million votes his party received.