Some non-leguminous plants are also able to interact with rhizobia and form nitrogen-fixing nodules. e.g. Parasponia.
Other non-leguminous plants absorb nitrogen from soil.
Leguminous plants fix nitrogen in soil. They contain symbiotic bacteria called rhizobia within nodules in their root systems, producing nitrogen compounds that help the plant to grow and compete with other plants. When the plant dies, the fixed nitrogen is released, making it available to other plants and this helps to fertilize the soil. On crop rotation, crops will absorb this nitrogen from soil.