Image copyright AFP Image caption Cheng Chieh (centre) had used a long fruit knife to attack fellow passengers

A Taiwanese man who killed four people in a mass stabbing on an underground train in Taipei has been executed.

Cheng Chieh, 23, was anaesthetised on Tuesday evening at a jail outside the capital before being shot three times.

Cheng had injured another 22 people when he boarded the train in May 2014 and stabbed passengers at random.

He had pleaded guilty to murder and attempted murder charges, and was sentenced to death after the court ruled he was not mentally ill.

Deputy Justice Minister Chen Ming said his death was "the only way to show publicly that justice had been served and to relieve the sorrow and pain of victims' families".

The case shocked Taiwan, where violent street crime and mass attacks are rare.

Taiwan restarted its use of the death penalty in 2010 after a five-year moratorium. It currently has 42 people on death row.

Analysis: Cindy Sui, BBC News, Taipei

Surveys have repeatedly shown a majority of Taiwanese support the death penalty, especially following crimes such as the subway stabbing and a recent spate of random violence, including the killing of children.

But Amnesty International and the European Commission, as well as local human rights groups, argue that Taiwan should put a halt to executions.

Local activists and lawyers say there is a widespread practice here of assuming guilt and conducting trial by media.

They say Taiwan's legal system does not properly assess suspects for mental illness, and believe judges often disregard problems in the investigation or trial process.

Death penalty opponents say that instead of trying to please the public, the government should instead get to the root of why Taiwan is seeing these unprecedented violent acts.