Media playback is unsupported on your device Media caption This animation from the University of Flinders, in Australia, recreates how the fish took up a side-by-side position while mating

Scientists believe they have discovered the origin of copulation.

An international team of researchers says a fish called Microbrachius dicki is the first-known animal to stop reproducing by spawning and instead mate by having sex.

The primitive bony fish, which was about 8cm long, lived in ancient lakes about 385 million years ago in what is now Scotland.

The research is published in the journal Nature.

They couldn't have done it in a 'missionary position' Prof John Long, Flinders University

Lead author Prof John Long, from Flinders University in Australia, said: "We have defined the very point in evolution where the origin of internal fertilisation in all animals began.

"That is a really big step."

Prof Long added that the discovery was made as he was looking through a box of ancient fish fossils.

He noticed that one of the M. dicki specimens had an odd L-shaped appendage. Further investigation revealed that this was the male fish's genitals.

"The male has large bony claspers. These are the grooves that they use to transfer sperm into the female," explained Prof Long.

Image copyright Flinders University Image caption Microbrachius dicki fossils are common - but nobody noticed the sexual organs until now

The female fish, on the other hand, had a small bony structure at their rear that locked the male organ into place.

Constrained by their anatomy, the fish probably had to mate side by side.

"They couldn't have done it in a 'missionary position'," said Prof Long. "The very first act of copulation was done sideways, square-dance style."

He added that the fish were able to stay in position with the help of their small arm-like fins.

"The little arms are very useful to link the male and female together, so the male can get this large L-shaped sexual organ into position to dock with the female's genital plates, which are very rough like cheese graters.

"They act like Velcro, locking the male organ into position to transfer sperm."

Image copyright Dr Brian Choo, Flinders University Image caption Copulation using this method did not stay around for long - fish reverted to spawning

Surprisingly, the researchers think this first attempt to reproduce internally was not around for long.

As fish evolved, they reverted back to spawning, in which eggs and sperm to fertilise them are released into the water by female and male creatures respectively. It took another few million years for copulation to make a come-back, reappearing in ancestors of sharks and rays.

Commenting on the research, Dr Matt Friedman, from the University of Oxford, UK, said: "The placoderm group (which includes Microbrachius dicki) is a well known group - the fossils are pretty common, and it's not as if this one was found in some far-off, exotic part of the world. It was found in Scotland.

"It is very remarkable that we haven't noticed this before."

Follow Rebecca on Twitter