A woman who lost the use of her limbs after a devastating stroke nearly 15 years ago has taken a sip of coffee by guiding a robotic arm with her thoughts.

The 58-year-old used a brain implant to control the robot and bring a flask of the coffee to her lips, the first time she had picked up anything since she was paralysed and left unable to speak by a catastrophic brain stem stroke.

Doctors hailed the feat as the first demonstration of an implant that directly controls a reaching and gripping robotic arm by sensing and decoding the patient's brain signals.

The work is part of a US clinical trial of an experimental implant called BrainGate that doctors see as a first step towards devices that can bypass damage to the nervous system and allow paralysed people to regain control of their limbs or amputees to move prosthetics.

"At the very beginning I had to concentrate and focus on the muscles I would use to perform certain functions," the woman said. "BrainGate felt natural and comfortable, so I quickly got accustomed to the trial."

Writing in the journal Nature, researchers described trials in which the woman, known only as S3, and a 66-year-old man referred to as T2, used the implant to control two different designs of robotic arm. The pill-sized device is surgically implanted a few millimetres into the motor cortex on the surface of the brain, where its 96 hair-thin electrodes pick up the patient's neural activity.

In a series of sessions, the patients learned to control the robot arm and pick up foam balls by imagining moving their own arm and hand. Neither patient could control the robotic arm as well as natural arm movements, but doctors were still delighted with their progress.

"These results are the first peer-reviewed demonstration of a three-dimensional reaching and grasping task using direct brain control of a robotic device," said Leigh Hochberg, a neuroengineer at Brown University in Rhode Island.

"One of the participants was also able to use the investigational BrainGate system to pick up a bottle of coffee and drink from it. This was the first time in nearly 15 years that she had been able to pick up anything solely of her own volition. The smile on her face when she did this is something that I and our whole research team will never forget," he added.

The man who took part in the trial had a brain stem stroke in 2006. Describing the experience afterwards – by spelling out letters with his gaze – he said: "I just imagined moving my own arm and [the robotic] arm moved where I wanted it to go."

The BrainGate device plugs directly into the brain, but protrudes through the skull where it is connected to a computer by a cable. More advanced devices are planned that can operate wirelessly and be implanted out of sight, beneath the skin.

One concern with brain implants is that they steadily lose their ability to sense neural signals as scar tissue forms around the ultrafine electrodes. An encouraging sign from the latest trial is that doctors could still record useful signals from the woman's brain five years after her implant was fitted.

John Donoghue, a co-author on the paper, and director of the Brain Institute at Brown University, said there was still much work to do. "We'll have truly met our goal when someone who lost mobility to neurological injury or disease can truly interact with their environment without anyone knowing that they are employing a brain-computer interface," he said.

In an accompanying article, Andrew Jackson at the Institute of Neuroscience at Newcastle University, said the study underlined how basic research was a crucial driver for such technological advances. In previous years, patients have used BrainGate to control a cursor on a computer screen and clench the outstretched fingers of a prosthetic hand into a fist.

"At a time when experimentation using nonhuman primates is increasingly controversial, it is worth noting that the results reported … draw directly on previous neural interface demonstrations in monkeys and on decades of basic research into the control of arm movements," Jackson writes.

"Although robotic arms may be of practical assistance, restoring movements of the patients' own limbs should remain the ultimate goal," he adds.