The celebration is based on the legend of two lovers, Orihime and Hikoboshi, who are represented by the stars Vega and Altair. The story goes as follows:
Orihime was the daughter of the god of the sky; the two of them lived in the heavens and every day, Orihime would diligently weave for her father. As time went on, the god grew concerned for his hard-working daughter, fearing that her chores would prevent her from ever finding love. He decided to introduce Orihime to Hikoboshi, a young cow herder who worked in the fields across the river, Amanogawa. (We know this 'river' as the Milky Way.) The pair quickly fell in love, abandoning their duties and, sadly, angering Orihime's father. As punishment, he separated them across the Amanogawa once more, such that they could never meet again. Naturally, Orihime was devastated and her tears weakened her father's resolve. Relenting, the god agreed that the lovers may meet once each year, on the 7th day of the 7th month, on the condition that they resumed their work.
A year passed and the day came when Orihime was permitted to cross the river to meet Hikoboshi. However, she arrived at the Amanogawa's bank only to discover that there was no bridge. Her hopes dashed once more, Orihime broke down in tears. Taking pity on her, a flock of magpies offered to help her cross. They made a bridge by hovering over the river, allowing Orihime to step on their wings and walk across, into Hikoboshi's waiting arms.