The Azerbaijan-born Guliyev dipped with 400m winner van Niekerk and Jereem Richards of Trinidad and Tobago with just 0.02 seconds separating the three medallists.
Guliyev clocked 20.09 with Van Niekerk in silver and bronze medallist Richards both given 20.11 with just a thousandth of a second between them.
It was the closest finish of all 200m medallists since 1987 when the same margin separated the top three in a race won by American Calvin Smith.
Van Niekerk was hoping to become only the second man to complete a world championship 200-400 double after American Michael Johnson in 1995.
"This competition was a massive roller coaster for me," the South African said. “Coming away with two medals – both a good colour, gold and silver – is great for my career.”
Guliyev, who switched nationality to Turkish six years ago, added: “Maybe at the next competition everyone will look at me instead."
Botswana’s Isaac Makwala, cleared by the IAAF to run in the men’s 200m after being declared medically fit to compete following an illness, finished sixth.
The seventh day of action also saw American Kori Carter put on a superb display of “blind” running from the outside lane to win the women’s 400m hurdles in 53.07, beating Olympic champion and compatriot Dalilah Muhammad (53.50) into second.
American Olympic champion Christian Taylor, who had talked of having another crack at breaking the 22-year-old triple jump world record of Britain’s Jonathan Edwards (18.29m), won gold but could only manage 17.68m ahead of compatriot Will Claye (17.63).
In the qualification events, German Johannes Vetter recorded the longest qualifying throw in the 34-year history of the championships in the men’s javelin – 91.20m.
Shaunae Miller-Uibo of the Bahamas bounced back from her 400m disappointment – where she was run out of the medals – to qualify for Friday’s final of the women’s 200m, equal fastest with Dutch sprinter Dafne Schippers (22.49).
Kenyan Hellen Obiri and Ethiopia’s Almaz Ayana, the 10,000m champion, were the two fastest qualifiers for Sunday's women’s 5000m final with Britain’s Laura Muir and Eilish McColgan also going through.