Richard R. Ernst, a chemist who won a Nobel Prize for devising precise techniques to analyze the chemical properties of atoms, helping create the foundation of magnetic resonance imaging, which has had far-reaching applications in science and medicine, died June 4 in Winterthur, Switzerland. He was 87.

His death was announced by the Swiss Federal Institute of Technology in Zurich (often called ETH Zurich), where he had been a student and professor. The cause was not disclosed.

Dr. Ernst worked primarily in the field of nuclear magnetic resonance spectroscopy (NMR), combining elements of chemistry, physics and engineering. He concentrated on building and refining electronic equipment that bombarded atomic nuclei with radio frequencies. He then devised mathematical methods to measure the atomic responses and determine their chemical properties.

The field of NMR spectroscopy had been advanced in the 1940s by two scientists, Swiss-born Felix Bloch (then working at Stanford University) and Edward Mills Purcell, an American researcher at Harvard.

They showed that radio waves could create a magnetic field that could alter the alignment of an atom’s nucleus. When the radio frequency is turned off, the nucleus tends to revert to its original alignment, giving off an electromagnetic signal that can be measured. Bloch and Purcell were jointly awarded the Nobel Prize in physics in 1952.

When Dr. Ernst began his research a few years later, there appeared to be relatively few practical applications for NMR beyond chemical analysis.

“We did not believe in the usefulness of the concept anyway,” Dr. Ernst wrote in an autobiographical essay for the Nobel organization, “and I finished my [doctoral] thesis in 1962 with a feeling like an artist balancing on a high rope without any interested spectators.”

A year later, he took a position with Varian Associates, a research company in Palo Alto, Calif. Using ideas suggested by U.S. scientist Weston A. Anderson, Dr. Ernst sought to make the magnetic resonance spectroscopy more exact. Instead of directing slow, sweeping radio waves at the atoms, Dr. Ernst and Anderson subjected them to short, intense pulses.

They varied the timing between the pulses, deriving new measurements that provided additional information about the properties of an atom’s nucleus. The enhanced form of magnetic resonance imaging, Dr. Ernst’s Nobel citation noted, was “like looking at the skyline of a mountain range and then looking at the whole range from an aircraft above.”

He achieved a further breakthrough by applying computer-assisted mathematical operations, called Fourier transformations, that dramatically improved the sensitivity of the magnetic resonance analysis. The finding — often called Fourier imaging — enabled chemists to study a greater number of atoms and to describe their properties in more vivid detail.

During the 1970s, after he had returned to Zurich as a professor, Dr. Ernst developed high-resolution, two-dimensional techniques that would allow larger molecules to be examined. Eventually, three-dimensional analysis of proteins and other molecules became possible, leading the way to magnetic resonance imaging, which has become widely used in diagnosing medical conditions.

In addition to the medical uses of MRI, there are many other applications, including analyzing the structure of chemical compounds and studying how drugs interact with various biological processes.

“It was my goal to develop something which could be used afterwards,” Dr. Ernst said in a 2001 interview published on the Nobel website. “I was more interested in really designing tools. So I’m a toolmaker and not really a scientist in this sense and I wanted to provide other people these capabilities of solving problems.”

Richard Robert Ernst was born Aug. 14, 1933, in Winterthur, where his ancestors had lived for 500 years. His father taught architecture at a technical high school.

As a child, Dr. Ernst played the cello and gave thought to becoming a composer. When he was 13, he found a box of chemicals that had belonged to an uncle, a metallurgical engineer.

“I became almost immediately fascinated by the possibilities of trying out all conceivable reactions with them, some leading to explosions, others to unbearable poisoning of the air in our house, frightening my parents,” Dr. Ernst wrote in his Nobel essay.

He began to read widely about chemistry and conducted experiments in the basement of his family’s house. He neglected his other studies to the point that he was almost expelled from school.

“Soon, I knew that I would become a chemist, rather than a composer,” he wrote. “I wanted to understand the secrets behind my chemical experiments and behind the processes in nature.”

At ETH Zurich — the same university Albert Einstein attended 50 years earlier — Dr. Ernst received a degree in chemical engineering. After military service, he received a doctorate in physical chemistry in 1962.

He returned to ETH Zurich in 1968, after five years in California, and taught and conducted research at the university until 1998. Dr. Ernst, who won numerous scientific awards, was the sole recipient of the 1991 Nobel Prize in chemistry. He learned of the honor when he was summoned to the cockpit while on a transatlantic flight.

Survivors include his wife of 58 years, the former Magdalena Kielholz, and their three children.

Dr. Ernst said it was important for scientists to have a wide range of interests outside their specialized fields. He played cello throughout his life and was said to have an encyclopedic knowledge of classical music. He also was a serious student and collector of Tibetan art — and used magnetic resonance techniques to examine the paint on the artworks. He arranged for the Dalai Lama to speak at his university in Zurich.

“Experiencing surprises was how it started,” Dr. Ernst told the Swiss news agency swissinfo.ch in 2011, describing how young people could become interested in chemistry.

“Let them do experiments! Sometimes people say chemistry is too dangerous — you can’t do this and that with children — but that’s not really true. There are a few rules which you have to obey, but otherwise you can do a lot of experiments.

“You experience the joy of discovery very often in chemistry.”