He was born in Kincardine-on-Forth and studied at the University of Edinburgh, where he graduated. Later he became professor at the University of Cambridge 1875 and was a member of the Royal Institution 1877. He developed a chemical formula for benzene and performed extensive work in spectroscopy for more than 25 years. In 1891 he discovered a process to produce liquid oxygen in industrial quantities. He developed an insulating bottle, Dewar flask, still named after him, to study low temperature gas phenomena. He also used this bottle to transport liquid gases like hydrogen 1898. In 1905 he observed that cold charcoal could produce a vacuum. This technique was quite useful for experiments in atomic physics. He is credited as the inventor of the vacuum flask.
Along with Sir Frederick Augustus Abel, developed the explosive whose common name is cordite.
He died in London.