Image copyright AFP Image caption Han Kuo-yo favours closer ties with China

Polls have closed in Taiwan's presidential election, whose outcome will shape the island's relationship with China.

Tsai Ing-wen, running for a second term, favours the status quo, and does not want closer ties with Beijing.

Meanwhile, her main rival, Han Kuo-yu, promises to ease tensions with China.

Ahead of the vote, Ms Tsai was leading in the polls - which some observers attribute to her support for the protests in Hong Kong.

Her stance is popular with those who fear Taiwan being overtaken by mainland China.

Beijing says the island must be unified with the mainland one day. President Tsai insists Taiwan's future should be decided by its 23 million people.

Image copyright EPA Image caption Tsai Ing-wen waves to supporters after voting in the capital, Taipei

Voters were also choosing the next members of the Taiwanese legislature, where Ms Tsai's party has had a majority.

About 19 million people were registered to vote in Saturday's election.

Polling stations closed at 16:00 (08:00 GMT) and results are expected before the end of the day.

What is Taiwan's status?

For practical purposes, Taiwan is an independent state - it has its own elected government, constitution and military.

But China has claimed sovereignty over it since the end of the Chinese civil war in 1949. It says Taiwan must eventually be reunited with China, by force if necessary.

China refuses to have diplomatic relations with any country that recognises Taiwan as a sovereign nation.

All but a handful of countries have picked Beijing, but most maintain an ambiguous relationship with Taiwan through trade. The US is also legally bound to supply Taiwan with the means to defend itself.

Where do the candidates stand on China?

Media playback is unsupported on your device Media caption China and its influence is a key issue in Taiwan's election

Ms Tsai wants to "maintain the existing mechanisms", according to her website - meaning she does not want to compromise Taiwan's de facto independence.

In a speech on the Hong Kong protests in June, she said "anyone who tries to undermine Taiwan's sovereignty and democracy, or use them as political bargaining chips, will fail".

She had also rejected Taiwan ever operating under the "one country, two systems" political system used in Hong Kong since it returned to China in 1997 - calling it "not viable".

Speaking to the BBC this week, she said Taiwan should "learn a lesson" from Hong Kong: "If we don't insist [on maintaining Taiwan's independence], we'll be losing everything we have now."

Mr Han and his party the Kuomintang (KMT) favour closer ties with China - which they say will bring economic growth - but do not seek unification.

The KMT once ruled China, before fleeing to Taiwan in 1949 after losing to the communist forces in the civil war.

Mr Han made a high-profile visit to Hong Kong and China in March, and has reportedly said a formal declaration of Taiwanese independence would be "scarier then syphilis".

A third candidate, James Soong, is running for his minor People First Party.

What are the other issues?

Media playback is unsupported on your device Media caption Three couples and a wedding to celebrate Taiwan marriage equality

Although the economy has grown during Ms Tsai's presidency, exports have fallen and wage growth is sluggish.

Saturday is also the first presidential election since Taiwan became the first place in Asia to legalise same-sex marriage.

The move was rejected in a series of referendums, but parliament passed a special law in order to comply with an earlier court ruling.

Ms Tsai said it was "a big step towards true equality".

What are the candidates' backgrounds?

Image copyright Reuters Image caption In 1993, Mr Han - seen here at a recent rally - punched the future Taiwanese president in parliament

Ms Tsai, 63, was a law professor before entering politics. She studied at Cornell in the US and the London School of Economics, as well as in Taiwan.

She is accused of being elitist, but her stance on same-sex marriage, language rights and other issues have won her support among younger voters.

Mr Han, 62 and currently mayor of Kaohsiung, is seen as more down-to-earth, and has projected a plain-talking everyman image.

He has embraced nicknames, including "bald guy", and a recent talk-show appearance saw the host apologise for poking fun at him.

"Continue, everyone is happy," he replied. "It's good in a society with a democratic and free atmosphere... just one request, no jokes about my hairline!"