This paper investigates the potential of blockchain technology to transform energy markets through peer-to-peer (P2P) energy trading. Blockchain enables decentralized, transparent, and secure energy transactions, allowing consumers to trade electricity directly, thereby reducing reliance on traditional centralized systems. The study examines the main challenges facing current energy markets, including inefficiencies, pricing complexities, and the integration of renewable energy sources. By utilizing smart contracts, blockchain automates and secures energy exchanges, giving consumers a more active role in the market. The paper also explores the technical aspects of implementing blockchain in energy trading, such as infrastructure needs and scalability issues, while addressing the regulatory, legal, economic, and environmental implications of this technology. Real-world examples and case studies underscore the potential of blockchain to foster more resilient, efficient, and sustainable energy markets.